简体   繁体   中英

Saving username and password for future sessions

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?

I'm not sure: You are using session in using (){} statement. When you get out of login controller, The using statement calls the Dispose method on the Session.

Hope this help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM