简体   繁体   中英

How to maintain User Session in asp.net?

I am working on an application. When a user logged in, a new session is created and session destroy when he log out.

in web.config I am using session mode = InProc like,

<sessionState cookieless="false" mode="InProc" timeout="50"></sessionState>

As you can see that after 50 min the session destroyed. All I want to know is how to maintain or regenerate user session if he/she not logout after 50 mins.
Thanks.

from the current config you provide asp.net will automatically make the session clear after 50mins. So in the application logic you have to implement the session validation to check if the session is empty and redirect the user back to login page.

Or instead you can implement manual page sign out logics, but creating a new page called 'logout.aspx' and in the page load event clear the session and redirect the user to login page. So whenever your user click on Singout link you can redirect the link to logout.aspx and it will clear the session and forward your user back to login page.

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