Cookie Problems

G

Guest

I''m having a problem with cookies that is driving me insane :).
- If a user comes to http://domain.com and a cookie is set for them, then the user for whatever reason jumps to http://www.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 http://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 http://www.domain.com, a cookie is set, then he/she jumps to http://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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top