Implementing "Remember Me"

G

Gary

Our site uses forms authentication where we always store the username in a
session("UserName"). We get that username from the logon screen. Now we
are implementing a "remember Me" checkbox where, if selected, we will call
FormsAuthentication.RedirectFromLoginPage(txtUser.value,
chkPersist.checked).

This works but the next time the remembered user logs in, they don't go
through our login page and the session("UserName") doesn't get set. I
suppose the the user name is inthe cookie but what property or method can I
use to retrieve it?
Thanks,
Gary
 
N

Nauzad Kapadia

if you are using FormsAuthentication, you really don;t need to waste a
session variable for storing the username.

Using HttpContext.Current.User.Identity.Name should return the "username"
value stored in the authentication cookie.

If you still want to store it in a session variable, then trap one of the
application events (like session_onstart, but i am not sure.) and assign the
above value to a session variable.

Regards,
Nauzad Kapadia [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top