Forum Moderators: open

Message Too Old, No Replies

Cookie problem

Possible IE6 bug?

         

jigga

9:44 pm on Jul 24, 2003 (gmt 0)

10+ Year Member



I'm having a problem with cookies that is driving me insane :).

- If a user comes to [domain.com...] and a cookie is set for them, then the user for whatever reason jumps to [domain.com...] one of the 2 happens:

1) The cookie we set can not be read (expected), but then a new one can not be written ether (I looked at the server headers and although the cookie information is sent, IE ignores it).

2) The cookie from [domain.com...] can be read, but you can not write to this cookie. Same here cookie is sent back from the server but IE ignores it.

Now, if its the other way around. If a user comes to [domain.com,...] a cookie is set, then he/she jumps to [domain.com:...]

The cookie can not be read (expected), but a new one can be written (as it should be).

So after driving my self insane, i whent out and tried it out in other servers to see if it was true. I tried 4 different sites which used cookies (for shopping carts). I did the same tests, (Go in via domain.com, add something to cart, then, jump to www.domain.com, cookie would not be overwritten. Then did the other way around, everything worked fine.)

Sample code:

cookietest.asp
------------------------------------------------------
<%

if request.querystring("action")="setcookie" then
Response.cookies("dog")=request.querystring("cookieval")
response.cookies("dog").Expires = Date + 1
end if

if request.querystring("action")="readcookie" then
response.write "Cookie Value is: " & request.cookies("dog") & "<br><br>"

end if

%>

<a href="cookietest.asp?action=setcookie&cookieval=12345">Set cookie</a>
¦
<a href="cookietest.asp?action=setcookie&cookieval=67891">Set cookie2</a>
¦
<a href="cookietest.asp?action=readcookie">Read cookie</a>
<br><br><p>
-------------------------------------------

Visit: yourdomain.com/cookietest.asp
Set a cookie
Read it to make sure its there.
Now type in www.yourdomain.com/cookietest.asp
Read the cookie (anything set?)
Set a cookie (By my tests cookie is not written)

Try it the other way around and it works!

Please somone help me out here i need to know if its a browser issue, or just my sloppy code :)

gangstah

10:35 pm on Jul 24, 2003 (gmt 0)

10+ Year Member



Well...I copied / pasted your code and it worked okay in my browser (IE6). Both times should read "67891" regardless of domain name used...right?

jigga

10:40 pm on Jul 24, 2003 (gmt 0)

10+ Year Member



As for reading, it has happened to me that even if i come from domain.com, then switch to www.domain.com, the cookie can still be read. But, you can not write to it. Thats why i have 2 links on the test, 1 writes a cookie value of "12345" the other "67891". A good test would be to Go to domain.com/script.asp, set cookie to 12345 (first link), read it to make sure. Then, jump to www.domain.com, set cookie to 67891 (second link), now read cookie. Does it say 67891 like it should, or 12345.

Note that if you go to your script via www.domain.com/script.asp first, it will work, so to make sure before you do the test, whipe the cookies in your system.