PDA

View Full Version : Cookie Deletion in Mozilla using ASP


Vlaad
04-22-2003, 02:46 AM
From what I've seen and read, this code below should reset my cookie values, and then remove the cookies entirely when it's moved to another page.

Unfortunately, it's doing nothing of the sort in Mozilla (actually, Phoenix, but it's 6of1, really).

From what I can tell, it works in IE.

Any thoughts would be muchly appreciated! (It's pretty urgent)



<%@ LANGUAGE=VBSCRIPT %>
<%
Response.Buffer=true

' Reset all cookies
Response.Cookies("TEsessionID") = "."
Response.Cookies("TEsessionID").Expires = Date() - 1
Response.Cookies("Alias") = "."
Response.Cookies("Alias").Expires = Date() - 1
Response.Cookies("UserLevel") = "."
Response.Cookies("UserLevel").Expires = Date() - 1
Response.Cookies("Invalid") = "."
Response.Cookies("Invalid").Expires = Date() - 1

%>

<HTML>
<HEAD><TITLE>Logging off...</TITLE>
<BODY>
Logging off... please wait
<%
' Redirect to the index
Response.Redirect "index.asp"
%>
</BODY>
</HTML>

glenngv
04-22-2003, 07:44 AM
try:

dExpire = dateadd("d",date(),-1)
Response.Cookies("TEsessionID") = "."
Response.Cookies("TEsessionID").Expires = dExpire
Response.Cookies("Alias") = "."
Response.Cookies("Alias").Expires = dExpire
Response.Cookies("UserLevel") = "."
Response.Cookies("UserLevel").Expires = dExpire
Response.Cookies("Invalid") = "."
Response.Cookies("Invalid").Expires = dExpire

if still not ok, try subtracting more days in the expiration

Vlaad
04-23-2003, 02:36 AM
Thanks for the reply glenngv, but it didn't help at all.

Mozilla still refuses to remove the cookies. It won't even modify the values using:

Response.Cookies("cookieName") = "value"

letalone completely remove the cookie.

Any more ideas?

Getting really desparate here...

glenngv
04-23-2003, 11:07 AM
are you sure cookies are enabled in mozilla? you can also check if the cookie is saved by viewing the cookie manager.

I also read regarding the Expires attribute:

Expires is write-only and is the date on which the cookie expires. Unless a date is specified, the cookie will expire when the session ends. If a date is specified, the cookie will be stored on the client's disk after the session ends.

So you should not specify Expires attribute and add Session.abandon to end the session.

Vlaad
04-24-2003, 02:10 AM
Yes, cookies were enabled. The problem seems to be that I can create them, but after creation they will not be set (Response.Cookies(key) = [string] does not affect the cookie at all after a value for the cookie has been set), nor deleted.

I've looked into this Session object mentioned (thnx glenngv), and it seems very valuable indeed. Creatable, settable, and very deletable! :)

I was just wondering if there was any downfall? I've done a little reading on the topic, but was interested in gathering people's personal opinions.

Thoughts?