Is there a way we can persist javascript variables across various pages? Suppose in Page A I am setting window.someVar = 5. Then I move to Page B, via clicking a hyperlink in A, and do something like alert(window.someVar) — I should get a message box displaying 5. Is there a technique to persist someVar as such…?
Is there a way we can persist javascript variables across various pages? Suppose in
Share
You could use the window’s name
window.nameto store the information. This is known as JavaScript session. But it only works as long as the same window/tab is used.