473,396 Members | 1,996 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,396 software developers and data experts.

Problem with deleting cookies

Hello,

I have problem deleting cookies and cookies values (using framework version
1.1 on W2003).

When I try to remove entire cookie, by calling
Response.Cookies.Remove("Test"), nothing happens, the cookie "Test" remains
unchanged.

When I try to remove one of cookie values, by calling
Response.Cookies("Test").Values.Remove(Key), all values are cleared (but
cookie itself remains), regardless what is used as Key - existing value
name, non-existent value name, empty string.

It seems to me as error in framework, because documentation says that it
should work. Or it's problem between keyboard and chair?

--
Michal A. Valasek, Altair Communications, http://www.altaircom.net
Please do not reply to this e-mail, for contact see http://www.rider.cz
Nov 17 '05 #1
1 5952
No bug with the Framework, although as you have learned the Remove method is
a bit confusing to have for the Cookie collection. (Maybe this is because
the cookie collection inherits from some other collection and yes, I'm too
lazy to look :-).

Anyway, the solution to your problem is to set the expiration date of the
cookie to some value in the past. Actually once you create a cookie, you
can't access it's expiration date despite it being a read/write property in
the framework. This is due to the official/Non-Microsoft (Netscape/w3c)
cookie specification.

So if you are not confused at this point, the true solution is to create
another cookie in ASP.Net that has the same cookie name as the one you want
to delete and specify an expiration date to some value in the past. The idea
is the old cookie will be replaced by the new one. Alternatively, don't
specify an expiration date is effectively the same thing. Both will delete
the cookie at the end of the user's session.

Hope this helps.
--
Peter O'Reilly
"Michal A. Valasek" <ne**@altaircom.net> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
Hello,

I have problem deleting cookies and cookies values (using framework version 1.1 on W2003).

When I try to remove entire cookie, by calling
Response.Cookies.Remove("Test"), nothing happens, the cookie "Test" remains unchanged.

When I try to remove one of cookie values, by calling
Response.Cookies("Test").Values.Remove(Key), all values are cleared (but
cookie itself remains), regardless what is used as Key - existing value
name, non-existent value name, empty string.

It seems to me as error in framework, because documentation says that it
should work. Or it's problem between keyboard and chair?

--
Michal A. Valasek, Altair Communications, http://www.altaircom.net
Please do not reply to this e-mail, for contact see http://www.rider.cz

Nov 17 '05 #2

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

Similar topics

14
by: Alec S. | last post by:
Hi, I'm using JavaScript and Cookies for some customization in a web page. There may be several values in the cookie with names that are not known at runtime. I need a way of deleting them. ...
8
by: WhatsPHP | last post by:
Hi I have a problem with cookies on an intranet page created in PHP. All the computers on the network except one works with cookies!! I though it was a general cookie problem, but every other...
4
by: macro | last post by:
when I use HttpWebRequest with CookieContainer object that handles cookies, if I have this cookie header in a response: Set-Cookie: CookieName=; path=/;expires=01-Jan-1999 00:00:00 GMT the...
4
by: macro | last post by:
when I use HttpWebRequest with CookieContainer object that handles cookies, i make more than one request and needs to handle cookies being added and removed between requests, just like a regular...
1
by: sameer | last post by:
Hi all, Environment : ASP.NET I am using cookies to store some data. this is done in a class which is called by a web page CookieCreate.aspx. Here is a little bit of code of how i create the...
1
by: seedy | last post by:
Good_day to you all! It's been a long time since i've visited here & even longer since posting a question or comment. Here goes. I can Not find the error in this cookie-based link jumpbox script...
1
by: Puja | last post by:
hi all, I have a problem. In my login page, after user logs in, I store userId in session.
2
by: =?Utf-8?B?YmlsbA==?= | last post by:
Hi I run windows EP service pack 2.I am on internet explorer 7.When I go into tools option delete history cookies ,temp file & so on .It doesnt work .I have deleted & reinstalled expl 7 but it...
7
by: cmrchs | last post by:
Hi, In Windows Vista: where does asp.net write its cookies? I use HttpCookie objCookie = new HttpCookie("nameCookie"); in Win2000 (and later) they used to be in C:\Documents and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.