Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I delete my browser cookies using javascript?

Tags:

javascript

How can I delete the session information from my browser by using javascript? Is it possible to do?


1 Answers

Session information is usually stored on the server. An HTTP request to a page that destroys the session would normally do the trick (using AJAX if you wish).

For cookies you can set the cookie expiry date to the current date, this will expire the cookie and remove it.

var d = new Date();
document.cookie = "cookiename=1;expires=" + d.toGMTString() + ";" + ";";
like image 128
Ady Avatar answered Mar 23 '26 11:03

Ady



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!