0

I'm implement aspnet identity with my MVC5 project. I have configured my project to use cookie authentication, form authentication and external authentication (facebook and google). Everything work fine.

Now i have a requirement to log whenever user log in system and i need to do some further logic. For the form authentication and external authentication i have a controller action that i can add my logic. However for the case user just come back system via cookie, how do i handle it?

khoa_chung_89
  • 975
  • 9
  • 25
  • Please can you elaborate on the sentence "However for the case user just come back system via cookie, how do I handle it"? I don't understand what you mean. – markp3rry May 01 '15 at 12:21
  • He means that if a user logs into the application, leaves at some point, then returns and is still logged in because the session hasn't expired, how does he handle tracking when a user has returned to his site (without re-authenticating). Most sites these days "remember" you after logging in for at least a few days. – Eckert May 01 '15 at 12:33

1 Answers1

2

I'm sure there's a better way to handle this, but a basic method would be to track all activity by the user, and then use timestamps to determine when a user was last active on your site.

Discussed here: Track user activity/actions for an asp.net mvc website?

OnExecuting filters here: https://msdn.microsoft.com/en-us/library/gg416513%28VS.98%29.aspx

Community
  • 1
  • 1
Eckert
  • 690
  • 4
  • 9
  • I know filter can use in this case but i want to write the exact logic to determine the login back event. I think time stamp should be the last solution if i cannot find any better :) – khoa_chung_89 May 01 '15 at 13:17