Click here to Skip to main content
16,019,983 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am trying to destroy session if user is idel for 15 min.
after destroying user should get msg like you are logdout.
after that he should automatic redirected to login page.
plz anybody can help.
plz plz
its urgent
Posted
Updated 7-Dec-11 2:53am
v2

Let's assume you have a site with a master page that has a few simple pages and that the user has logged in. As part of the login process assign something to the Session, perhaps like
C#
Session.Add(Key, Value);
. You can then test for this value each time the user, for instance, navigates to another page or initiates a PostBack event.

You could do:

C#
// Pseudo code.
if (Session[Key] == null)
{
    // Do something: user no longer valid.
}


If the Session has expired the Session variable will be null which you can test for and take the appropriate action.
 
Share this answer
 
write this code in web.config file under
C#
<system.web>

C#
<sessionstate timeout="15"></sessionstate>


by default it is of 20 mins. when user will do something after 15 mins. then page will reload and redirect to login page.

hope it'll help you...
Don't forget to mark if it helps you. :)
 
Share this answer
 
v2

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