PDA

Click to See Complete Forum and Search --> : Response.Cookies glitch


Dec 21st, 2000, 09:20 PM
I have a script that writes cookies. I'm well aware of the no-output-before-writing-cookies rule. I write all cookies at the very top of my scripts before anything else happens. I added another line of code that wrote one more cookie and for some reason it won't write that last one! There are several lines of Response.Cookies("blah") = "blah" above it and they all write their cookies just fine. For some reason that last one just won't write! The last cookie content isn't anything special, just the text "YES". Any thoughts on why that last one doesn't write?

monte96
Dec 21st, 2000, 10:11 PM
Post your code so we can help you.

Dec 22nd, 2000, 08:51 AM
Originally posted by monte96
Post your code so we can help you.





<%
Response.Cookies("A31DC").Expires = "12/31/1990"
Response.Cookies("A31DC") = "YES"
Response.Cookies("A31DC").Expires = DateAdd("m", 3, Date)
%>
<html>
<body bgcolor=#400080 background="" text=Silver link=#9966FF vlink=#9966FF alink=#9966FF leftmargin=15 topmargin=5>
<Font face=Verdana>
Welcome to the AREA31 Discount Gaming Club!!!<BR>
Your membership will expire <%= DateAdd("m", 3, Date) %>.
</Font>
</body>
</html>

This is the entire asp page. The response.cookies lines above are just like the lines in another script which writes the cookies just fine with one exception. The future expiration above is set with the dateadd function, in the other script the future expiration is text. i.e. "12/31/2020" for basically -no- expiration.

The dateadd fuction returns what you'd expect, a numeric date string which is 3 months in the future. It should work. Is there a limit on the number of cookies you can write? The other script writes 9 cookies.

monte96
Dec 26th, 2000, 11:51 PM
Try doing a response.write of your dateadd result. I think that is where your problem lies. There is no limit on the number of cookies. I've written pages that use many more than 9. Microsoft's documentation use Now() instead of Date in the DateAdd function. Perhaps there is a reason. I'm not totally sure why they included both functions in the language since they seem to return the same thing.