How to timeout an active session in C# .NET

Posted on 2011-10-13
Medium Priority
Last Modified: 2012-08-13
I'd like to set our active sessions to timeout after 12 hours. I already have an idle timeout set up, but I'm curious how to set a timeout for an active session.
Question by:Josh_Blade
LVL 28

Expert Comment

ID: 36964682
Set a cookie at the beginning of the session and set an expiration of 12 hours. Check that cookie every postback and if it doesn't exist, call Session.Abandon(). That will clear the session and force the session start to occur again and a new cookie to be created.
LVL 16

Accepted Solution

Easwaran Paramasivam earned 2000 total points
ID: 36966618
LVL 14

Expert Comment

by:nishant joshi
ID: 36968553
Response.AddHeader("Refresh", Session.Timeout + ";URL=Logoff.htm");

Author Closing Comment

ID: 36968747
Thanks a lot.

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question