A Cookie Error is a Sometimes Thing

A Cookie Error is a Sometimes Thing

am 14.09.2007 18:56:03 von Pupkin

Hi,

I've a script that sets a cookie, but when I visit the page occasionally
get this error that goes away when I immediately refresh the page:

"Object doesn't support this property or method:
'Response.Cookies(...)"


Here's the code in question:

Response.Cookies("CKName")("ED").Expires = DATE + 3650


I've read elsewhere that the ".Expires" method is not supported, but
it's in most of the online cookie tutorials I've looked at, and, like I
said, it works when I refresh the page.

I also saw a comment on this board that this is not how you create a
permanent cookie with ASP. If not, then how?


Thanks.

Re: A Cookie Error is a Sometimes Thing

am 14.09.2007 19:19:23 von Anthony Jones

"Pupkin" wrote in message
news:MPG.21545cfc2fda1499897e2@news.giganews.com...
> Hi,
>
> I've a script that sets a cookie, but when I visit the page occasionally
> get this error that goes away when I immediately refresh the page:
>
> "Object doesn't support this property or method:
> 'Response.Cookies(...)"
>
>
> Here's the code in question:
>
> Response.Cookies("CKName")("ED").Expires = DATE + 3650
>
>
> I've read elsewhere that the ".Expires" method is not supported, but
> it's in most of the online cookie tutorials I've looked at, and, like I
> said, it works when I refresh the page.
>
> I also saw a comment on this board that this is not how you create a
> permanent cookie with ASP. If not, then how?
>


The cookie is the object retrevied with Cookies("CKName"). ("ED") is a value
with in the cookie and returns a string.
Cookies can be multivalued which what you appear to be using but you can
only expire the cookie as whole not an individual value. This code should
perhaps be:-

Response.Cookies("CKName").Expires = Date + 3650


--
Anthony Jones - MVP ASP/ASP.NET
..

Re: A Cookie Error is a Sometimes Thing

am 14.09.2007 20:06:38 von Pupkin

In article <#1uHmNv9HHA.4612@TK2MSFTNGP03.phx.gbl>, Ant@yadayadayada.com
says...
> "Pupkin" wrote in message
> news:MPG.21545cfc2fda1499897e2@news.giganews.com...
> > Hi,
> >
> > I've a script that sets a cookie, but when I visit the page occasionally
> > get this error that goes away when I immediately refresh the page:
> >
> > "Object doesn't support this property or method:
> > 'Response.Cookies(...)"
> >
> >
> > Here's the code in question:
> >
> > Response.Cookies("CKName")("ED").Expires = DATE + 3650
> >
> >
> > I've read elsewhere that the ".Expires" method is not supported, but
> > it's in most of the online cookie tutorials I've looked at, and, like I
> > said, it works when I refresh the page.
> >
> > I also saw a comment on this board that this is not how you create a
> > permanent cookie with ASP. If not, then how?
> >
>
>
> The cookie is the object retrevied with Cookies("CKName"). ("ED") is a value
> with in the cookie and returns a string.
> Cookies can be multivalued which what you appear to be using but you can
> only expire the cookie as whole not an individual value. This code should
> perhaps be:-
>
> Response.Cookies("CKName").Expires = Date + 3650
>


Great. That makes a lot of sense. Thanks!