473,399 Members | 3,888 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.

How to clear cookies in ASP?

Hi,

I have a website that would set two cookies when a user logs in
successfully.

<%
response.cookies("login_status")="OK"
response.cookies("login_id")="12345" 'This value is from database.
response.cookies("login_id").domain="mysitexyz.com "
%>

and I have a question in "removing/deleting/cleaning the cookie when
the user logs out.

From my understanding there are two methods -

#1 (I am currently using)
response.cookies("login_status")=""
response.cookies("login_id")=""

#2
response.cookies("login_status").expires=now
response.cookies("login_id").expires=now

My questions is, what's the difference, advantage and disadvantage of
these two methods?

I am asking this because I have noticed that there are some problems
in #1. In my computer (I use IE7) if I login as one user, logout, and
then login as another user, the cookie value will get mixed up.
Somehow the response.cookies("login_status") can display correctly but
response.cookies("login_id") cannot. But if I clean my browser cache,
close my IE and reopen it, both cookies work fine.

Anyone has ideas or suggestions will be highly appreciated.

Jan 2 '08 #1
9 38285
in general, the first simply changes the value of the cookie, the second destroys the cookie.

the problem may be touching upon many subjects. Whether or not the login check is working properly depends upon how you are testing
for login existence.

Are you looking for an empty value in the cookie or checking for the existence of a cookie.

Jan 2 '08 #2
On Jan 2, 10:38*am, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere
dot comwrote:
in general, the first simply changes the value of thecookie, the second destroys thecookie.

the problem may be touching upon many subjects. Whether or not the login check is working properly depends upon how you are testing
for login existence.

*Are you looking for an empty value in thecookieor checking for the existence of acookie.
I am not looking for an empty value or the existence of it. My problem
happens when I login->logout->login and the cookie value cannot be
stored correctly. I will explain my question more specifically as
below.

1. I tried to login my website with one account (id=12345), I got the
cookie values as follows (which is correct) -

response.cookies("login_status")="OK"
response.cookies("login_id")=rs("myuserid") 'This value is from
database...
response.cookies("login_id").domain="mysitexyz.com " 'Note that I only
set up domain for cookie login_id

If I Response.Write("login_id="& Request.Cookies("login_id") ), I get
login_id=12345
which is correct.

2. Then I log out. The cookie values were set to ""

response.cookies("login_status")=""
response.cookies("login_id")=""

3. After that, I use another user account (id=67890) to login, but I
found that "ONLY" the cookie login_id cannot get the correct value. If
I want to output them like

Response.Write("login_status="& Request.Cookies("login_status")
Response.Write("login_id="& Request.Cookies("login_id")

I got
login_status=OK
login_id=

which is wrong, I should be able to get "login_id=67890" as my correct
result. The login ID and PW were both correct, so it couldn't be the
DB problem. The only one problem that I can think of is at the time
that I logout, I didnt "clean/remove" my cookie completely.

So anyone knows where the problem is? and how to solve it?

Jan 4 '08 #3
your logic seems fine but it must be something else in your code or when you are testing the cookie.

After logging in, redirect to a new page and put the test in the new page . See if the problem repeats or is resolved.
Jan 4 '08 #4
Jon Paal [MSMD] wrote on 05 jan 2008 in
microsoft.public.inetserver.asp.general:
your logic seems fine but it must be something else in your code or
when you are testing the cookie.

After logging in, redirect to a new page and put the test in the new
page . See if the problem repeats or is resolved.
Please Jon, quote! This is not email.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 5 '08 #5
I suggest you find another news-reader.
Jan 5 '08 #6
Jon Paal [MSMD] wrote on 05 jan 2008 in
microsoft.public.inetserver.asp.general:
I suggest you find another news-reader.
Who are you referring to?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 5 '08 #7
"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot comwrote in message
news:13*************@corp.supernews.com...
I suggest you find another news-reader.
What Newsreader do you use?

--
Anthony Jones - MVP ASP/ASP.NET
Jan 6 '08 #8
Anthony Jones wrote:
"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot comwrote in
message news:13*************@corp.supernews.com...
>I suggest you find another news-reader.

What Newsreader do you use?
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jan 6 '08 #9

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:uM**************@TK2MSFTNGP02.phx.gbl...
Anthony Jones wrote:
"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot comwrote in
message news:13*************@corp.supernews.com...
I suggest you find another news-reader.
What Newsreader do you use?

X-Newsreader: Microsoft Outlook Express 6.00.2900.3138

D'oh! nice one Bob I didn't think to check the headers. ;)

Jon, I use OE as well. Yet I'm still irritated that when I'm forced to
click between messages trying to get a handle on what the comments should be
applied to. Although not as irritated as opening one of Evertjan's messages
that it bangs on about netiquette yet again. :P
--
Anthony Jones - MVP ASP/ASP.NET
Jan 6 '08 #10

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

Similar topics

4
by: Brian Burgess | last post by:
Hi all, Anyone know of any special issues with storing cookies with ASP? I'm trying this with two browsers: One is IE 6.0 with cookies set to 'prompt'. This has been working properly as any...
20
by: Brian Burgess | last post by:
Hi all, Anyone know if this is possible? If so, on which page would the cookie be? .. On the page calling a function defined in the include file? thanks in advance.. -BB
0
by: RobbRoss | last post by:
I'm stuck using C# on a project and am trying to clear the Cookies. The Response.Cookies.Clear(); is not working. What needs to be done to make this remove the cookies? I'm testing this on my...
6
by: Mark | last post by:
Hi... I've come across some weird bug with Response.Cookies. Or maybe it will be called "by design" but for the life of me I can't figure out what purpose it would serve. If you're setting a...
0
by: Serge | last post by:
Good Day Folks I'm using the following code when creating, reading, and removing a cookies. <% ' writing cookie Response.cookies("OracleLogin")("p_userid")="fcs_system"...
3
by: DC Gringo | last post by:
I have an app that I can't seem to clear out server resources with a button onclick event: The session variables seem to be disappearing properly, but the aspnet_wp.exe process stays where it...
9
by: ad | last post by:
I use the codes below to clear the cookie: HttpCookie myCookie = new HttpCookie("us_id"); myCookie.Expires = DateTime.Now.AddDays(-1d); Response.Cookies.Add(myCookie); It do well when the...
4
dmjpro
by: dmjpro | last post by:
can't clear the history and cookies in js thanks in advance
3
by: sasimca007 | last post by:
Hello friends, I have a general doubt, i.e when we create a project, we have a login form and when we enter the username and password if those are correct we login otherwise...
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: 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
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...
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.