lastlogindate and FormsAuthentication (cookie) - how?

Discussion in 'ASP .Net' started by =?Utf-8?B?cGF0cmlja2RyZA==?=, Jul 12, 2007.

  1. Hi everyone!

    How do I know when a user has logged in if he logs in using a cookie?

    By default, when he logs in entering a username and password,
    I can catch that inside my authenticate method,
    but what if he logs in automatically?

    (I'm not using the new login controls and/or object model nor do I want to
    use that)


    Where should I update the lastlogindate in such a case? In

    Application_AuthenticateRequest? The code for this function is as follows:



    Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As
    EventArgs)

    Dim userInformation As String = [String].Empty

    If HttpContext.Current.User IsNot Nothing AndAlso _
    HttpContext.Current.User.Identity.IsAuthenticated AndAlso _
    TypeOf HttpContext.Current.User.Identity Is FormsIdentity Then
    'If Request.IsAuthenticated Then

    Dim sCookieName As String = FormsAuthentication.FormsCookieName
    If Request.Cookies(sCookieName) IsNot Nothing AndAlso
    Request.Cookies(sCookieName).Value <> "" Then
    Dim fat As FormsAuthenticationTicket =
    FormsAuthentication.Decrypt(Context.Request.Cookies(sCookieName).Value)
    userInformation = fat.UserData

    Dim info As String() = userInformation.Split(New Char() {";"c})

    HttpContext.Current.User = New
    helperclasses.CustomPrincipal(User.Identity,
    Convert.ToInt32(info(0).ToString()), info(1).ToString(), info(2).ToString(),
    Convert.ToInt32(info(3).ToString()), info(4).ToString(),
    Convert.ToInt32(info(5).ToString()), info(6).ToString())
    End If
    End If

    End Sub


    Thanks in advance!
     
    =?Utf-8?B?cGF0cmlja2RyZA==?=, Jul 12, 2007
    #1
    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. George Durzi

    FormsAuthentication Cookie Q

    George Durzi, Oct 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    3,099
    George Durzi
    Oct 16, 2003
  2. Brian Shannon

    FormsAuthentication Expired Cookie

    Brian Shannon, Aug 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    373
    Brian Shannon
    Aug 18, 2004
  3. tshad
    Replies:
    3
    Views:
    1,250
    tshad
    Jan 17, 2005
  4. Bill Henning
    Replies:
    8
    Views:
    9,527
    King Adrock
    Nov 9, 2005
  5. William
    Replies:
    5
    Views:
    507
    Dominick Baier
    Feb 23, 2007
Loading...

Share This Page