views:

12

answers:

2

Hey,

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.

+1  A: 

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).

Oded
A: 

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.

Tim S. Van Haren