I have a database table with 4 columns (email, token, tokenDate (DateTime), isOnline (bool))
What I am trying to do in ASP.NET MVC is have an application where the user goes to a page like this Home/Index?email=xxxxx@xxxxxxx.com and when they goto the page, they are login, now what I could do it when they goto the page is this:
- Find the user in the database table
- Mark
isOnlineto true - Set the
tokenDatetoDateTime.Now - Create a random
tokenand set that as token - Create a web cookie with the same value as token
And when someone else (or the same person) with the same email tries to goto the page
- Find the user in the database table
- If
isOnlineis marked astrueand the cookie does not exist and if it does check against the one in the database, if fails boot them out, if success, they can enter.
My question is what token would I want to create so they original user is still authenticated so if they close their browser or goto another page they can still goto the main page where they authenticated?