I am setting a session cookie in one page using
setCookie("cookietime","1000");
And resetting it to "" on going back to previous page
setCookie("cookietime","");
When I go back I am showing an alert after seeting the cookie to "". it is showing "" in alert. But in the next page it still shows "1000". Is the cookie page specific
Cookies are stored client side and are computer+browser specific not page specific! I guess you are using document.cookie which should persist through the session - they persist even when the page is refreshed. Using window.name will only persist through the same browser window but will clear on page refresh. HTML5 localStorage may be a suitable alternative.
Relates question: Persist javascript variables across pages?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With