473,396 Members | 2,002 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.

Trouble removing cookies

I am having trouble removing cookies that I created with my site. Here is
the code I am using to try and remove them:
If Not Request.Cookies("username") Is Nothing Then
Response.Cookies.Remove("username")
If Not Request.Cookies("password") Is Nothing Then
Response.Cookies.Remove("password")
Is there something I am missing here? Even after I do a Session.Abandon()
the cookies still seem to be there. Is there another step that is necessary?
Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Feb 24 '06 #1
3 1219
Nathan,

Instead of removing the cookies (I believe that just removes them from the
server memory and not the client) you should overwrite them on the client.

If Not Request.Cookies("username") Is Nothing Then
Response.Cookies("username") = ""
End If

Oh, and even an empty cookie may not be equal to "Nothing" because it is a
string you may need to test for "" instead.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I am having trouble removing cookies that I created with my site. Here is
the code I am using to try and remove them:
If Not Request.Cookies("username") Is Nothing Then
Response.Cookies.Remove("username")
If Not Request.Cookies("password") Is Nothing Then
Response.Cookies.Remove("password")
Is there something I am missing here? Even after I do a Session.Abandon()
the cookies still seem to be there. Is there another step that is
necessary? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Feb 24 '06 #2
I figured out how to remove them, which is to set the Expires property to
somewhere in the past and the use the Response.Cookies.Add() method.
However, what is the point in removing the cookies from the server memory if
they get resent with every Request anyway?
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:OI**************@tk2msftngp13.phx.gbl...
Nathan,

Instead of removing the cookies (I believe that just removes them from the
server memory and not the client) you should overwrite them on the client.

If Not Request.Cookies("username") Is Nothing Then
Response.Cookies("username") = ""
End If

Oh, and even an empty cookie may not be equal to "Nothing" because it is a
string you may need to test for "" instead.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I am having trouble removing cookies that I created with my site. Here is
the code I am using to try and remove them:
If Not Request.Cookies("username") Is Nothing Then
Response.Cookies.Remove("username")
If Not Request.Cookies("password") Is Nothing Then
Response.Cookies.Remove("password")
Is there something I am missing here? Even after I do a Session.Abandon()
the cookies still seem to be there. Is there another step that is
necessary? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/


Feb 25 '06 #3
Nathan,

I'm not certain about that myself... It really may just be the object they
chose to hook up cookies with. It looks like the object is ultimately
inheriting from something similar to arraylist (if it isn't arraylist itself
I didn't bother to check). It may not be that they intended Remove to even
be used. It may just have come along for the ride via inheritance.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:O1**************@TK2MSFTNGP15.phx.gbl...
I figured out how to remove them, which is to set the Expires property to
somewhere in the past and the use the Response.Cookies.Add() method.
However, what is the point in removing the cookies from the server memory
if they get resent with every Request anyway?
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote
in message news:OI**************@tk2msftngp13.phx.gbl...
Nathan,

Instead of removing the cookies (I believe that just removes them from
the server memory and not the client) you should overwrite them on the
client.

If Not Request.Cookies("username") Is Nothing Then
Response.Cookies("username") = ""
End If

Oh, and even an empty cookie may not be equal to "Nothing" because it is
a string you may need to test for "" instead.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I am having trouble removing cookies that I created with my site. Here is
the code I am using to try and remove them:
If Not Request.Cookies("username") Is Nothing Then
Response.Cookies.Remove("username")
If Not Request.Cookies("password") Is Nothing Then
Response.Cookies.Remove("password")
Is there something I am missing here? Even after I do a
Session.Abandon() the cookies still seem to be there. Is there another
step that is necessary? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/



Feb 27 '06 #4

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

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
9
by: Alexander Stippler | last post by:
Hi, I've got trouble with some well known issue. Iterator invalidation. My situation: for (it=v.begin(); it!=v.end(); ++it) { f(*it); } Under some circumstances, f may alter the container...
3
by: Nospam | last post by:
I would like to remove cookies once I sign out of a website or close explorer is there such an option to do this? thanks
2
by: dave | last post by:
I have 2 pages... in the first page i check to see for the existance of the cookie, if found do something else set the value and set the cookie. (cookie gets set ok) I use the following code to...
3
by: Angelos Karantzalis | last post by:
hi guys, I've a couple of web services. The first one authenticates a user, and saves the principal in the session object. The second one authorizes after reading the user data from the...
2
by: Owen | last post by:
I have a web app that is a mixture of ASP and ASP.NET pages. Largely the only data passed between them is via the querystring, or by reading from a database. However there is a requirement for...
3
by: Nathan Sokalski | last post by:
I am having trouble removing cookies that I created with my site. Here is the code I am using to try and remove them: If Not Request.Cookies("username") Is Nothing Then...
3
by: shawn | last post by:
I am having a hard time finding an easy way to remove a reference to another .net project that I am no longer using (ASP 2.0 - this was an available option in 1.0). Other projects have a list of...
3
by: Kevin Blount | last post by:
I've created a quick set of test scripts, and I'm finding that cookies don't work as I would expect(i.e. the same as they do in original ASP. In original ASP I could set a cookie on one page, set...
3
by: Groove | last post by:
Hey guys - hoping you can help me out here. I'm using asp.net 2 (VB) and trying to set and retrieve values from a cookie. I've done this a few times before w/o a problem but I seem to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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
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
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...

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.