How to destroy cookies on page refresh

2019-05-02 01:10发布

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??

2条回答
Ridiculous、
2楼-- · 2019-05-02 01:52

May be you could remove cookies on page unload.

For example, with jQuery:

$(window).unload(function() {
  //Destroy cookies here
});
查看更多
戒情不戒烟
3楼-- · 2019-05-02 02:14

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.

查看更多
登录 后发表回答