Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Cookies not persisting accross pages ASP.NET

 
Thread Tools Search this Thread
Old 03-29-2006, 09:20 AM   #1
Default Cookies not persisting accross pages ASP.NET


HI all,

I have this problem I have two pages on one I use this code to set some
cookies:

Response.Cookies("cokFirstName").Expires = DateTime.MaxValue
Response.Cookies("cokFirstName").Value = txtForename.Text
Response.Cookies("cokMiddlename").Value = txtMiddlename.Text

If I break the code there and check the cookies they all have the right
values

However after I redirect to another page and try to read these cookies
I get this error

Referenced object 'Item' has a value of 'Nothing'.

Why is this happening ??
PLEASE HELP



Brano
  Reply With Quote
Old 03-29-2006, 11:43 AM   #2
Jason Hales
 
Posts: n/a
Default Re: Cookies not persisting accross pages ASP.NET

After you've redirect are you then referring to them via the Request
object, rather than Response?

Are you redirecting to a different virtual path, if so consider setting
the cookie.Path property

  Reply With Quote
Old 03-31-2006, 09:26 AM   #3
Brano
 
Posts: n/a
Default Re: Cookies not persisting accross pages ASP.NET

Hi yes I am,

I have found the problem it is that ASP.NET only supports up to 20
cookies and I had about 45 so the last 20 always overwritten the first
20 cookies...

and i was only testing the first one...

Sorted it out using cookie keys

Response.Cookies("Key")("Name") = string


Jason Hales wrote:
> After you've redirect are you then referring to them via the Request
> object, rather than Response?
>
> Are you redirecting to a different virtual path, if so consider setting
> the cookie.Path property


  Reply With Quote
Old 03-31-2006, 12:51 PM   #4
Jason Hales
 
Posts: n/a
Default Re: Cookies not persisting accross pages ASP.NET

I never knew that limit existed

I guess you could serialise all of your cookies into a single cookie
value - but then you might exceed the maximum length for a cookie -
which I believe is 64K

Mind you that's an awful lot of stuff your saving as cookies

  Reply With Quote
Old 03-31-2006, 02:00 PM   #5
Juan T. Llibre
 
Posts: n/a
Default Re: Cookies not persisting accross pages ASP.NET

re:
> I have found the problem it is that ASP.NET only supports up to 20 cookies


The number of cookies is not limited by ASP.NET.
It is controlled by the browsers, per the W3C's 2109 RFC.

http://msdn.microsoft.com/library/de...okietheory.asp

Browser Cookie restrictions

Browsers place restrictions on the number of cookies that can be held at any one time.

The restrictions are:
a.. 20 cookies maximum per domain.
b.. 4096 bytes per cookie description.
c.. 300 cookies overall maximum.

RFC 2109 says at least these maximums.
Netscape's specification and browsers say at most these maximums.

There is now a pref in Mozilla and Firefox that allows you to modify the maximum cookies per host.

IE still implements RFC 2109. I don't know if IE7 will address that.




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Brano" <> wrote in message
news: oups.com...
> Hi yes I am,
>
> I have found the problem it is that ASP.NET only supports up to 20
> cookies and I had about 45 so the last 20 always overwritten the first
> 20 cookies...
>
> and i was only testing the first one...
>
> Sorted it out using cookie keys
>
> Response.Cookies("Key")("Name") = string
>
>
> Jason Hales wrote:
>> After you've redirect are you then referring to them via the Request
>> object, rather than Response?
>>
>> Are you redirecting to a different virtual path, if so consider setting
>> the cookie.Path property

>




  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump