Skip to content

Tag: local-storage

Clear local storage on session clear

I want to clear localStorage on session clear, i.e when the user exits the browser. I am using window.onbeforeunload for this purpose, as shown below. The problem is that this function also removes item also on browser reload. Is there any way around this, or is it any better way on implementing this? Edit: T…