简体   繁体   中英

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. i tried setting them and close the page and re-open the page again. but the cookie is still there. i have checked the cookie status and it is shown session instead of expire date.

and cookies expired it will automatically delete from client side?or it is visible but unusable?

You can use the .unload event to delete cookies before the browser / page closes.

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

Similarly you can use it with .load event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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