[thelist] asp.net: update cookie value to log user out
Gary McPherson
lists at ingenyus.net
Mon Oct 11 18:11:20 CDT 2004
----Original Message----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Casey Crookston
Sent: 11 October 2004 21:06
To: thelist at lists.evolt.org
Subject: [thelist] asp.net: update cookie value to log user out
> I. User fills in User ID and Password text box correctly.
>
> II. Cookie is set:
>
> dim login_cookie as HttpCookie = New HttpCookie("loggedIn")
> login_cookie.Values.Add("login_correct","yes")
> login_cookie.Expires = today.AddDays(1+today.DayOfWeek)
> Response.Cookies.Add(login_cookie)
>
> II. Now, user wants to log out, so clicks on the "Log Out"
> link. What's the best course of action at this point?
> Change the value of the cookie to ("login_correct","no")? If
> so, is there a response.cookies.update method?
> Or do you do it all over again?
>
> dim login_cookie as HttpCookie = New HttpCookie("loggedIn")
> login_cookie.Values.Add("login_correct","no")
> Response.Cookies.Add(login_cookie)
>
> Or is there a better way of doing this?
>
> Thanks,
>
> Casey
Yes, there is. ASP.NET provides Forms Authentication to provide exactly this
type of functionality without you having to faff around with cookies. Some
useful links are here:
http://samples.gotdotnet.com/quickstart/aspplus/doc/formsauth.aspx
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconthecookieauthenticationprovider.asp
http://www.asp101.com/articles/cynthia/authentication/default.asp (full
example)
There are tons more articles on the subject, but those should get you
started at least. Hope that helps,
Gary
More information about the thelist
mailing list