Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,
i have implemented login page with remember me checkbox option which login in to the site, and i have used formsauthentication for the security, but remember me option not working properly when i am using the one of the method of forms authentication, but why i am not getting that, plz help me what method should i follow or do i need to change my code, my code is follows
in login button click;
C#
protected void btnLogin_Click(object sender, EventArgs e)
{
    FormsAuthentication.RedirectFromLoginPage(txtUname.Text.Trim(),chkRember.Checked);
}

while debugging it is showing true but functionality is not getting working, plz help me to solve this.

in logout out button i have written:-

C#
protected void btnlogout(object sender, eventargs e)
{
    formsauthentication.signout();
    response.redirect("Login.aspx");
}
Posted
Updated 3-Dec-14 22:47pm
v3

1 solution

Here you need to understand what this does. The FormsAuthentication() method here sets a cookie that has a property called 'IsPersistent', which is set to true if Remember Me is checked or has value true.
Now what should happen is whenever a user enters the url, he should be redirected to the Home page rather than the login.
For this, in the Login Get method, you need to check for the existence of session & also cookie and if both are present i.e. not null, then check if IsPersistent is true, if true then redirect from there to the home page directly.
Sometimes while on debug mode when we stop the process, the session gets destroyed, but the browser persists the cookie details that contains the identity name. So, when you run again, session would then be oviously null, so check if cookie is present and session is null, if that is so, based on the cookie unique username create a session and redirect to home page(remember to check always for isPersistent).
Remember Me doesnot work[^]
I hope this helps you understand.
Post back your queries if any.
Happy to help..:)
Thanks.
 
Share this answer
 
v2
Comments
pavan_ kumar 4-Dec-14 5:11am    
but, i have seen in one site to work like these options and in that they also used the same which i have used, no need to check all conditions like session, cookie and all
and the site link as follows, u can observe here
http://www.codedigest.com/Articles/ASPNET/112_Implementing_Forms_Authentication_in_ASPNet_20.aspx
[no name] 4-Dec-14 5:13am    
yes this should work out. Since this did not work for you I provided an alternate solution.
pavan_ kumar 4-Dec-14 5:15am    
k, do u have corresponding code related to this requirement????
[no name] 4-Dec-14 5:19am    
See my updated solution, provided a link. You can get to know why it sometimes does not work.
Sorry I cant provide the exact codes, but the way I have explained please follow, it will surely work out. Else try with adding your code and then post I will check that and edit.
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900