|
|
I have a Login.aspx page where if the user has the 'Remember Me' checked then it stores their username in a cookie for a year so whenever they hit the login page (session timed out, or they clicked logout at some point) the username is pre-filled. The pre-filling is working fine, in fact it works every time. The flip side is if they login and the 'Remember Me' isn't checked, then that cookie (whether it exists or not) needs to go away. The going away part never happens, even though I'm expiring the cookie.
Here's the cookie name, at the top of the form:Here's what's in my page load event:Code:Private Const m_LoginCookieName As String = "SiteName"And here's in the login button of the login control:Code:If Not Page.IsPostBack Then Dim myCookie As HttpCookie = Request.Cookies(m_LoginCookieName) If myCookie IsNot Nothing Then If myCookie.Values("UserName") <> String.Empty Then loginHome.UserName = Request.Cookies(m_LoginCookieName).Values("UserName") loginHome.RememberMeSet = True End If End If End IfWhen I debug the page load, I see not only does the cookie always exist (meaning me setting it to a previous day doesn't expire it at all) but the expire date (the property is type Date) is always #12:00:00 AM# even though when I debug the Login Button it's being set to #3/17/2010 7:41:24 AM# (one day previous) when it gets re-added to the Request.Cookies collection.Code:Dim myCookie As New HttpCookie(m_LoginCookieName) If loginHome.RememberMeSet Then 'Duration: 1 year myCookie.Expires = DateTime.Now.AddYears(1I) myCookie.Values.Add("UserName", loginHome.UserName) Else 'Time to expire it myCookie.Expires = DateTime.Now.AddDays(-1I) myCookie.Values.Add("UserName", String.Empty) End If Request.Cookies.Add(myCookie)
I'm thinking this is a pretty major bug in the FW, this logic I got from 2 MSDN articles, but in case I'm wrong and there's something with my code I'm looking for 2nd opinions.
I'm using VS2008, but it's targeting the 2.0 FW.
Currently using: VS 2005 & 2008 Pro w/sp1 & VS 2010 Ultimate on Win7 Ultimate x64.
There are 3 kinds of people in the world: Those who can count and those who can't.
4 out of 3 people have trouble with fractions.
Windows has a 64 bit GUI for a set of 32 bit extensions on a 16 bit shell for an 8 bit OS using a 4 bit kernel made by a 2 bit company that can't stand 1 bit of competition.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks