Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > lastlogindate and FormsAuthentication (cookie) - how?

Reply
Thread Tools

lastlogindate and FormsAuthentication (cookie) - how?

 
 
=?Utf-8?B?cGF0cmlja2RyZA==?=
Guest
Posts: n/a
 
      07-12-2007
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.Cookie s(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!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FormsAuthentication.Encrypt and Decrypt not playing nicely =?Utf-8?B?TWlrZQ==?= ASP .Net 0 08-31-2005 07:59 PM
FormsAuthentication and Session Joe ASP .Net 2 08-02-2005 01:22 AM
FormsAuthentication and "unable to validate data": HELP! Harrie Verveer ASP .Net 2 06-27-2005 11:08 AM
FormsAuthentication.Encrypt and SSL Gawel ASP .Net 2 08-01-2004 09:33 AM
FormsAuthentication and session_end Darren Clark ASP .Net 1 05-25-2004 08:14 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57