Click here to Skip to main content
15,910,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In My application,when a user login into application i update the login_status='Y' in database
If the user idle for more 20 minutes it will automatically redirect to login page
How to update database Login_status='N'
Posted
Updated 25-Dec-12 22:19pm
v2

It could be achived with help of Session state management

XML
<configuration>
<system.web>
 <sessionstate mode="InProc" timeout="20" regenerateexpiredsessionid="true" />
</system.web>
</configuration>


then if in your web app exists Global.asax , in taht module
declare method
C#
 void Session_End(object sender, EventArgs e)
{
//perform your DB logic here!!!
}
 
Share this answer
 
It might depend on what membership provider[^] you are using. But first of all, use sessions! Let's suppose you do. Than set the session timeout[^] to the same value - by default it is 20 minutes, thus you will probably not need to set anything.
Now, you can intercept the session timeout event in code: implement a Session_End handler in global.asax
See: http://www.techrepublic.com/article/working-with-the-aspnet-globalasax-file/5771721[^]

If you are using asp.net 2.0 read these also:
ASP.NET Session End Event Fires Immediately After Session Start - Resolved[^]
http://blogs.msdn.com/b/nikhiln/archive/2007/06/21/detecting-session-timeout-in-asp-net-2-0-web-applications.aspx[^]
 
Share this answer
 
Comments
Oleksandr Kulchytskyi 26-Dec-12 5:23am    
Nice one !)
write the code to update login status of user to N at the page load of login page
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900