简体   繁体   中英

MVC 5 use session to store login information?

This is more a question regarding a proper approach than a coding issue. Let's say I have an MVC application with a registration and login system. I have a SQL database where I store the registration information and connect to it when the user wants to log in.

Once I authenticate the user, is it ok to store the information required ( like username ) into a session variable and then reference that throughout the application?

It's possible but not recommended due to many reasons. Use ASP.NET Identity to do all that. Latest versions of Visual Studio come with great sample MVC projects that implement full registration / login / lost password etc. loop.

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