Implementing "Remember Me"

Discussion in 'ASP .Net Security' started by Gary, Jan 6, 2004.

  1. Gary

    Gary Guest

    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
    Gary, Jan 6, 2004
    #1
    1. Advertising

  2. Gary

    Teemu Keiski Guest

    Hi,

    the name should be available just by using:

    User.Identity.Name

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist


    "Gary" <> wrote in message
    news:...
    > 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
    >
    >
    Teemu Keiski, Jan 6, 2004
    #2
    1. Advertising

  3. 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]


    "Gary" <> wrote in message
    news:...
    > 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
    >
    >
    Nauzad Kapadia, Jan 26, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TCORDON

    "Remember Me" Functionality

    TCORDON, Mar 24, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    4,983
    Tampa.NET Koder
    Mar 25, 2005
  2. Guest
    Replies:
    1
    Views:
    615
    Bruce Barker
    Oct 17, 2005
  3. gencode
    Replies:
    4
    Views:
    9,938
    gencode
    Nov 8, 2005
  4. Rob R. Ainscough
    Replies:
    3
    Views:
    4,997
    tdavisjr
    Mar 22, 2006
  5. Frank Miverk
    Replies:
    0
    Views:
    658
    Frank Miverk
    Apr 18, 2007
Loading...

Share This Page