Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > How to clear cookies in ASP?

Reply
Thread Tools

How to clear cookies in ASP?

 
 
tanya.wang@gmail.com
Guest
Posts: n/a
 
      01-02-2008
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.

 
Reply With Quote
 
 
 
 
tanya.wang@gmail.com
Guest
Posts: n/a
 
      01-04-2008
On Jan 2, 10:38*am, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere
dot com> wrote:
> 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?

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      01-05-2008
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)
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      01-05-2008
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)
 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      01-06-2008
"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot com> wrote in message
news:(E-Mail Removed)...
> I suggest you find another news-reader.
>


What Newsreader do you use?

--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      01-06-2008
Anthony Jones wrote:
> "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot com> wrote in
> message news:(E-Mail Removed)...
>> 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"


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      01-06-2008

"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Anthony Jones wrote:
> > "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot com> wrote in
> > message news:(E-Mail Removed)...
> >> 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.


--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Give Request.Cookies and Response.Cookies is there any reason to use another method to use cookies? _Who ASP .Net 7 09-18-2008 07:49 PM
Response.Clear() doesn't clear David ASP .Net 2 01-31-2008 08:32 PM
Unrecognized element 'add' after <clear></clear> InvalidLastName ASP .Net Web Services 3 03-06-2007 03:07 AM
Toolbar customization -- clear cache, cookies, etc? ttfg Firefox 2 04-02-2005 04:54 PM



Advertisments