lastlogindate and FormsAuthentication (cookie) - how?

G

Guest

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!
 

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,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top