How to timeout an active session in C# .NET

Posted on 2011-10-13
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

    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

    LVL 14

    Expert Comment

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

    Author Closing Comment

    Thanks a lot.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now