PDA

Click to See Complete Forum and Search --> : cookie not working - help needed!


shamloo
May 9th, 2001, 04:03 PM
I need help with the script below.
If the cookie is set, a message should say so. If not, a message will say so and then set the cookie and it's value.

for some reason this does NOT work:
<% Option Explicit
Response.Buffer = true

Dim expDate, aspPoll

aspPoll = "aspPoll"
expDate = "2001-05-09 21:42" ' for this version this is static, it will be dynamic in the near future

Response.write("------------------------<BR>")
Response.write("ExpireDate: "& expDate &"<BR>")
Response.write("TodayDate: "& now)
Response.write("<BR>------------------------<BR><BR>")

Response.write(Request.Cookies(aspPoll) &"<BR><BR><BR><BR><BR><BR>")

IF (Request.Cookies(aspPoll) <> "") THEN
Response.write("the cookie is set and running!<BR>"&_
"Cookie Value: "& Request.Cookies(aspPoll))
ELSEIF (Request.Cookies(aspPoll)="") THEN
Response.write("This cookie is not set yet...<BR>")
Response.write("<B>&nbsp;&nbsp;Creating cookie....</B><BR>")

Response.Cookies(aspPoll).Expires = CDate(expDate)
Response.Cookies(aspPoll).Domain = ".Caffeine"
Response.Cookies(aspPoll).Path = "/"
Response.Cookies(aspPoll) = "someText"
Response.write("reload the page and this cookie will be set!!!<BR>")
Response.write("Cookie value: "& Request.Cookies(aspPoll) &"<BR><BR>")
ELSE
Response.write("some other text here...")
END IF
%>
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">

</BODY>
</HTML>


I really appreciate any help since this is the last thing missing in my poll-system.

thanks,
David

Sastraxi
May 9th, 2001, 04:38 PM
Are you sure that you set it correctly? Show us your setting code.

mentor22
May 9th, 2001, 05:20 PM
Try the following code.
It works fine for me

<% Option Explicit
Response.Buffer = true

Dim expDate, aspPoll

aspPoll = "aspPoll"
expDate = "2001-05-11 21:42" ' for this version this is static, it will be dynamic in the near future

Response.write("------------------------<BR>")
Response.write("ExpireDate: "& expDate &"<BR>")
Response.write("TodayDate: "& now)
Response.write("<BR>------------------------<BR><BR>")

Response.write(Request.Cookies(aspPoll)("Main") &"<BR><BR><BR><BR><BR><BR>")

IF (Request.Cookies(aspPoll)("Main") <> "") THEN
Response.write("the cookie is set and running!<BR>"&_
"Cookie Value: "& Request.Cookies(aspPoll)("Main"))

ELSEIF (Request.Cookies(aspPoll)("Main")="") THEN
Response.write("This cookie is not set yet...<BR>")
Response.write("<B> Creating cookie....</B><BR>")

Response.Cookies(aspPoll).Expires = CDate(expDate)
Response.Cookies(aspPoll)("Main") = "sometext"
Response.Cookies(aspPoll)("Domain") = ".Caffeine"
Response.Cookies(aspPoll)("Path") = "/"
Response.write("reload the page and this cookie will be set!!!<BR>")
Response.write("Cookie value: "& Request.Cookies(aspPoll)("Main") &"<BR><BR>")
Response.write("Domain value: "& Request.Cookies(aspPoll)("Domain") &"<BR><BR>")
Response.write("Path value: "& Request.Cookies(aspPoll)("Path") &"<BR><BR>")

ELSE
Response.write("some other text here...")
END IF
%>
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">

</BODY>
</HTML>

shamloo
May 10th, 2001, 07:44 AM
thanks a lot mentor22!
it works excellent now, but Im not sure where I did wrong.
Is it that I did not use this syntax: Response.Cookies("cookieName")("subItem") ??
if not, can you(or anybody) tell me where my code was incorrect ?

I don't just want to have the code working, I also want to understand it :D

thanks again,
David