dparkes
asked on
ASP will not delete cookie created with Javascript
Hi, I'm currently doing some maintenance on a site that uses JavaScript and plain ASP code (not Asp.Net), and I'm now very confused.
I am unable to delete a cookie for some reason. I've tried the method they say to use everywhere:
Response.Cookies("LineItem s").Expire s = Date() - 1
And it does nothing.
I'm wondering if the JavaScript cookie is the same as a regular cookie though, because I am using a cookie viewer (IECookiesView) and don't see the cookie there in any case. Yet I can see view the cookie using the JavaScript command:
alert(document.cookie);
The cookie is set in JavaScript with a command like this:
document.cookie = "LineItems=this is what i want my cookie to be";
I'm very confused. Is this not a cookie? Why does it not show up in IECookiesView and undeletable with asp?
I am unable to delete a cookie for some reason. I've tried the method they say to use everywhere:
Response.Cookies("LineItem
And it does nothing.
I'm wondering if the JavaScript cookie is the same as a regular cookie though, because I am using a cookie viewer (IECookiesView) and don't see the cookie there in any case. Yet I can see view the cookie using the JavaScript command:
alert(document.cookie);
The cookie is set in JavaScript with a command like this:
document.cookie = "LineItems=this is what i want my cookie to be";
I'm very confused. Is this not a cookie? Why does it not show up in IECookiesView and undeletable with asp?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Slamhound, This gets me halfway there.
Yes it looks like my cookie was not correctly formatted. Using a setCookie function, now it appears in the cookie explorer...
For some reason I had trouble calling the code you gave me and used this instead though, which in my case seems to work:
function setCookie(Name, Value, Expire) {
document.cookie = Name + "=" + escape(Value) + ";expires=" + Expire;
}
However, the cookie is still not getting deleted using ASP code.
I've tried my original code, and hielo's above, but it's having no effect on the client side cookie.
Yes it looks like my cookie was not correctly formatted. Using a setCookie function, now it appears in the cookie explorer...
For some reason I had trouble calling the code you gave me and used this instead though, which in my case seems to work:
function setCookie(Name, Value, Expire) {
document.cookie = Name + "=" + escape(Value) + ";expires=" + Expire;
}
However, the cookie is still not getting deleted using ASP code.
I've tried my original code, and hielo's above, but it's having no effect on the client side cookie.
If formatting has fixed one problem I'd guess that it continues to be an issue.
Can you validate in your cookie explorer that everything is formatted properly. That the name is right, the value is right and the expiration date is right once JS creates it.
The other thing to try is
Response.Cookies("LineItem s") = ""
or
Response.Cookies("LineItem s") = Null
This way we can be sure that your ASP is manipulating the cookie even if it can't expire it.
Can you validate in your cookie explorer that everything is formatted properly. That the name is right, the value is right and the expiration date is right once JS creates it.
The other thing to try is
Response.Cookies("LineItem
or
Response.Cookies("LineItem
This way we can be sure that your ASP is manipulating the cookie even if it can't expire it.
Response.Cookies("LineItem