views:

202

answers:

2

Hi all,

I have an ASP.NET login control on a page, with the "Remember Me" checkbox displayed. I have checked in trace and the authentication cookie is being created, I have sliding expiration set and a timeout of 60000, yet when I return to the website the login is not being remembered.

Any ideas where else I can check?

Thanks,

Darryl

A: 

I've found that whenever any problems are potentially related to cookies, that Firecookie is an invaluable tool for finding out what is actually going on...

davidsleeps
The cookie is being set - from trace:EAAAuthCookie 62A7CC6485422A2393A3BDD015293F45E0652A3B23A5089C7D500235D288A17934B365C553159D9CB53F0A28516E3A3F48FC40435EAE0E00DDBC47F4B15774902845F1E8D21722AC068DD727C809FAAA754E8DF268FE672397A076D5469EF1CDA2099859DBDB5A70287E8091575C8689 238
Gogster
have you checked the expiration date in FireCookie? Make sure it isn't set to "Session"...otherwise it'll behave as you describe...
davidsleeps
+1  A: 

Correct! The Remember Me checkbox doesn't do anything for you and why should it?

After succesful login; you could create the cookie from code and (when entering the page or masterpage or whatever) attempt to read the previously made cookie to get your credentials.

Or you could use the SetAuthCookie when using FormsAuthentication; reference: http://msdn.microsoft.com/en-us/library/sxb3b282(vs.71).aspx

riffnl
Yeah sorry, I am setting the auth cookie, here is the code:private void OnAuthenticate(Object sender, EventArgs e) { if (Membership.ValidateUser(UserName.Text, Password.Text)) { if (chkRememberMe.Checked) { FormsAuthentication.SetAuthCookie(UserName.Text, true); } else { FormsAuthentication.SetAuthCookie(UserName.Text, false); } Response.Redirect("/members"); } else { Response.Redirect("/login?lif=true"); } }
Gogster
Are you reading the formsauth cookie when you enter the page afterwards? (silly question perhaps)
riffnl
Apparently not that silly... d'oh!
Gogster

related questions