473,395 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

Mar 29 '06 #1
4 1955
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

Mar 29 '06 #2
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


Mar 31 '06 #3
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

Mar 31 '06 #4
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" <bp****@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr 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


Mar 31 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: TG | last post by:
This is more of a pain than I thought it would be. I need a simple code segment to determine whether a browser accepts cookies or not. When I pass variables between pages when cookies are turned...
3
by: Marcin Gorzynski | last post by:
Hi Our partner is using our page in a frame. That couses a problem because our domain is unable to issue the cookie also session does not work. each time you click in the frame new session is...
2
by: Lee Wilkie | last post by:
Dear All, I'm new to ASP.NET and have been developing a small app at work to test Forms Authentication. When running on my development machine (using http://localhost/TestApp/Login.aspx for...
19
by: Siobhan | last post by:
Hi What is the recommended way to store a user's database credentials across the pages of a web application so that each time the database is accessed the system doesn't have to ask them for their...
0
by: Claudio | last post by:
I have a demo app where cookies does not work. The first page create a cookies. The second read the contet. If I browse the pages via IE6.0 the pages does not work. If I browse the pages via...
3
by: insomniac | last post by:
Hello, I'm not a newbie to cookies, however I am stumpped by a receent issue that has come up. I am running my web application through a frame that belongs to another company. This application...
0
by: Homer J. Simpson | last post by:
A few weeks ago I asked for suggestions on how to persist a tree's node state to cookies, without causing postbacks on each click in the tree. I had a single .aspx file, with a row of buttons on...
1
by: Nikron | last post by:
Hi, I'm having an issue with the ASP.NET 2.0 Treeview control and persisting its' state accross requests. My Control is embedded within a master page and is used for site navigation. My problem...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.