7

Hello I need to destroy javascript cookies on a page refresh. I need to set a new bunch of cookies on every page load which help me render the web page based on user options. Is there a method to destroy cookies on a page refresh??

3
  • If you rewrite the cookies the old values disappear.
    – mplungjan
    Jul 29, 2010 at 17:16
  • well what would the event be, when I rewrite my cookies??
    – sai
    Jul 29, 2010 at 17:22
  • if your page loads after onunload then you are refreshing so you could test the age of a cookie you set in onunload and onload see if it is less than a minute old, you refreshed
    – mplungjan
    Jul 29, 2010 at 17:51

2 Answers 2

3

May be you could remove cookies on page unload.

For example, with jQuery:

$(window).unload(function() {
  //Destroy cookies here
});
3
1

You need to detect the page refresh, have a look at:

Detecting Page Refreshes :: Using JavaScript on Client-Side

Once you know that, you should be able to delete the cookies.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.