473,399 Members | 3,656 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,399 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 1297
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

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: 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
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
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.