What would be the proper way to end (kill) cookies in my case:
- When user first connect to web site it connect him/her to Index.
- Then user put username and password.
- It connect to his account ("_Layout.cshtml" with header starts - header have navigation menu, to see some results).
- Now! If user close this tab or close browser without clicking on logout, happan this: When user connect again to website it redirect him/her to index (where is login form) with layout with header shown. So user can again navigate to his/her account by clicking on navigation menu - do not have to login again.
I whant to do, when user close his tab or browser, cookies ends (or is killed), so it logout user automaticaly.
So far I have only this in my login controller set is:
if(ModelState.IsValid)
...
FormsAuthentication.SetAuthCookie(user.Username, false);
For Logout I have this:
public ActionResult LogOut()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Home");
}
And in web confing I have set this:
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
:)