Possible Duplicate:
Javascript cookie delete
Please let me know how to delete specific cookie (I have the name of the cookie its enough..).
I really dont have an idea (I dont know JS well...) and when I searched in Google I didn't find a good solution.
Thank you.
EDIT: If I can't delete the cookie - let me know how to change the value to "" (empty..), its ok too.
Stolen from here:
function del_cookie(name) {
document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}
This sets the cookie value to nothing (name + '=;
) and sets the expiration time to the past (expiring it immediately).
Try this (adapted from here):
function DeleteCookie(name, path, domain)
{
path = (path ? ";path=" + path : "");
domain = (domain ? ";domain=" + domain : "");
var expiration = "Thu, 01-Jan-1970 00:00:01 GMT";
document.cookie = name + "=" + path + domain + ";expires=" + expiration;
}
Essentially, you delete cookies by setting their expiration date to a date guaranteed to be in the past.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With