When using Forms authentication is there a way to redirect the user back to the login page if they are inactive for a given period of time.

Posted on 2004-11-11
Last Modified: 2013-12-23
I have an application that uses forms authentication to Authenticate against the Active Directory.  If there is no activity for 30 minutes or more and the user then tries to do anything, navigate to a different page, click the submit button etc. I want them to be redirected back to the login page.

In the Web.config file I have the following entries:

    <authentication mode="Forms">
        <forms loginUrl="logon.aspx" name="adAuthCookie" timeout="30" path="/"></forms>

    <sessionState mode="InProc"
            sqlConnectionString="data source=;user id=sa;password="

What happens when the use tries to navigate to a new page after 30 minutes is the session has expired so when the code on the page they are navigating to looks for a session variable it throws an error.  I want them to be sent back to the login page where they can login again, the session variables will be reset and they will then get redirected to the page they want.
Question by:leskelly
    LVL 7

    Expert Comment

    When the user logs in are you setting the Session.Timeout equal to the Forms.Timeout?  Are you saving a persistant authentication cookie or just using the standard cookie?  Please could you post your authentication procedure?

    Author Comment

    I resolved the problem by adding code that checks one of the sessions variables and , if it is blank redirects the user to the login page.  I forgot to close this question and I apologize for that.


    Accepted Solution

    PAQed with points refunded (250)

    Community Support Moderator

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
    When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure ( It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
    The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
    The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

    754 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

    19 Experts available now in Live!

    Get 1:1 Help Now