For Programmers: Free Programming Magazines  


Home > Archive > ASP > March 2004 > cookie problem, virtual directory related









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cookie problem, virtual directory related
Jaakko T Oksa

2004-03-28, 9:55 pm

The following script sets,resets or displays the contents of a cookie.

When I place the script in a directory under the iis root, let's
say "mysite" (http://localhost/mysite/tst.asp) it works as expected.

When I create a virtual directory "mysite" and point it to the directory
where the script is, the cookie can no longer be set after it has been
cleared, even though it is accessed in the same location
(http://localhost/mysite/tst.asp)

Anyone know why?

<%

' save this code in tst.asp

If Request("mode")="display" Then
Response.Write "cookie=" & request.cookies("cookie") & "<br><br>"
End If

If Request("mode")="set" Then
Response.Cookies("cookie") = "12345"
Response.Cookies("cookie").Expires = DateAdd("d", 2, Date)
Response.Cookies("cookie").Path = "/"
End If

If Request("mode")="clear" Then
Response.Cookies("cookie") = ""
End If
%>

<a href="tst.asp?mode=display">display cookie</a><br>
<a href="tst.asp?mode=set">set cookie</a><br>
<a href="tst.asp?mode=clear">clear cookie</a>

<%
' end
%>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com