FIX: Random Cookies Disappear When Different Cookie Is Set to Nothing in Internet Explorer 4 and 5 (232907)



The information in this article applies to:

  • Microsoft Active Server Pages
  • Microsoft Internet Explorer (Programming) 4.0
  • Microsoft Internet Explorer (Programming) 4.01
  • Microsoft Internet Explorer (Programming) 4.01 SP1
  • Microsoft Internet Explorer (Programming) 4.01 SP2
  • Microsoft Internet Explorer (Programming) 5

This article was previously published under Q232907

SYMPTOMS

In Active Server Pages (ASP) pages, cookies appear to work but then suddenly "disappear." This occurs only when you view the pages with Microsoft Internet Explorer 4 and 5, not Internet Explorer 3.

If you loop through the Response.Cookies collection, you may see the name of the missing cookie separated by a semicolon from the name of a cookie that was set to an empty string.

CAUSE

Internet Information Server 4/Active Server Pages don't handle nameless cookies correctly. Nameless cookies get concatenated before the next cookie name. Consider the following valid cookie headers from the browser:
SomeNamelessValue;
cookie2=ABC;
				
You cannot use the following to get the value of cookie2:
Request.Cookies("cookie2")
Instead, you can use the following to get the value ABC:
Request.Cookies("SomeNamelessValue;cookie2")

RESOLUTION

There are two workarounds for this problem:
  • "Expire" the cookie.
  • Set the cookie to some known value that means it is empty, and then test for that value in the code, instead of testing for an empty string.

STATUS

This problem was corrected in Windows NT 4 Service Pack 6.

MORE INFORMATION

This bug became apparent because of a change in behavior between Internet Explorer 3 and Internet Explorer 4/5.

In Internet Explorer 3, you could use the following to set a cookie value to nothing:
Response.Cookies("cookie1")=""
				
The browser would return a cookie header that looked like this:
cookie1=;
				
However, in Internet Explorer 4 and 5, the equal sign is dropped and the following cookie header is returned to the server:
cookie1;
				

Modification Type:MinorLast Reviewed:9/23/2005
Keywords:kbHotfixServer kbQFE kbbug kbfix kbQFE KB232907 kbAudDeveloper