![]() |
|
|
|||||||
![]() |
ASP Net - Cookies not persisting accross pages ASP.NET |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
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 |
|
|
|
#5 |
|
Posts: n/a
|
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 > |
|