简体   繁体   English

在页面更改,页面关闭和页面加载期间删除cookie

[英]delete cookies during page change , page close and page load

i wanted to delete all my cookies in these events.Some says that by setting the cookie expire date to NULL or -1 will work. 我想删除这些事件中的所有cookie。有人说,通过将cookie过期日期设置为NULL或-1就可以了。 i tried setting them and close the page and re-open the page again. 我尝试设置它们并关闭页面,然后再次重新打开页面。 but the cookie is still there. 但是cookie仍然在那里。 i have checked the cookie status and it is shown session instead of expire date. 我已经检查了cookie状态,并显示了会话而不是过期日期。

and cookies expired it will automatically delete from client side?or it is visible but unusable? 并且Cookie过期了,它将自动从客户端删除?还是可见但无法使用?

You can use the .unload event to delete cookies before the browser / page closes. 您可以使用.unload事件在浏览器/页面关闭之前删除cookie。

    $(window).unload(function() {
       $.cookies.del('name_of_your_cookie');
    });

Similarly you can use it with .load event. 同样,您可以将其与.load事件一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM