I'm setting up my first MVC site and I just implemented a security controller and views.
However what I don't understand is how I can persist the logged in user data across my controllers.
For example the user logs in with email/password. I can then verify that the email and passwords match and I do the following:
FormsAuthentication.SetAuthCookie(userLogin.UserName, false);
return View("../Home/Index");
Now say for example I want in the Index view to present data that only a user can see.
I have a table setup but it's based on the user_id.
Can I either save the user_id when they login or is there something already available to me to access their email(user)? (I could then look up the id via the email if necessary)
My MVC is setup for Forms authentication:
<authentication mode="Forms">
<forms loginUrl="~/Security/Login" timeout="2880" />
</authentication>
and I decorated the controllers with the "[Authorize]" annotation.