I have a application where to access the database user has to be in a session. When the user logs in, in browser he/she gets authenticated and session starts. Here is an example
[HttpPost]
[AllowAnonymous]
public ActionResult CustomLogin(LoginModel login)
{
using (var loginsSession = SoSession.Authenticate(login.Username, login.Password))
{
var x = 0;
}
return null;
}
Problem Everytime user gets out of this controller's login function, the session expires. If the user wants to access database again, I need to create new session but the problem is I don't know how to store the username and password so that I don't have to ask user to login again and again. Is there some smart way to store username and password somewhere so that I can use it till the user logs out from the browser?