Click to See Complete Forum and Search --> : cookies problem.
CrazyGaz
06-23-2003, 05:29 PM
I have a problem with cookies. I have the following code to write the cookie.
Response.Cookies("UserName")="test"
Response.Cookies("UserName").Expires = "Jan 1, 2010"
but when I run it I get this error.
Wrong number of arguments or invalid property assignment: 'Response.Cookies'
if anyone has experienced this problem or can help then please do :)
cheers, Gaz.
Ribeyed
06-23-2003, 07:05 PM
Hi,
you need # around the date:
Response.Cookies("UserName").Expires = #31/12/2010 00:00:00#
hope this helps
Ribeyed
06-24-2003, 04:31 AM
Feel free to object if you feel you know better
You are correct, stupid US dates, lol.
Anyway to add to this you can use an valid VBScript to set the expire date, for example you can do this:
response.write.Cookies("UserName").Expires = DateAdd("m", 1, Now)
this would expire the cookie 1 month from now. Each cookie would have its own expiration date, which you can change at will by setting its Expire property. SInce this property is read-only, you can't find out when a cookie will expire, so you should plan carefully what you use cookies for and aviod changing their usage after you have created them.
Ribeyed
06-24-2003, 08:11 AM
Hi Dave,
got me thinking on this one but i think i was correct in saying it is read-only and not write-only, but could be wrong, trying to find an definitive answer. If it was write-only then you wouldn't be able to read/retrieve the values of the cookie. The cookies collection doesn't expose a Remove method to delete individual cookies. To delete a cookie you set its expiration date to a past date, as soon as the expiration date is set to before the current date, the cookie ceases to exist.
CrazyGaz
06-24-2003, 10:21 AM
I tried that but as I expected there was no change the error still remains, the error is occuring on the first line.
Response.Cookies("UserName")="test"
any more ideas?
|EDIT| The problem is Apache (what I use instead of ISS) but it is perfect for everything else so I'll have to try and configure it :/
chhers, Gaz |EDIT|