Skip to main content
Inspiring
August 27, 2008
Answered

Session Timeout Redirect

  • August 27, 2008
  • 4 replies
  • 4631 views
When a user's session times out as specified in cfapplication sessiontimeout, my users are directed to a page if they hit refresh or click on one of the page links. Works just like it should, however...

Where/how do I specify the page to which I would like them redirected?
    This topic has been closed for replies.
    Correct answer health-pact
    Thanks for all of the suggestions. The redirect at the top of each page did not work. The "session timed-out" redirect was apparently happening in application.cfm.

    I have a weird web site which is a web site in wwwroot, with an application.cfm, and another web site in a directory in wwwroot, with a second application.cfm. When I hit the time-out, I was actually being sent back to the application.cfm in wwwroot.

    So, in the wwwroot appl.cfm, I added a check for a timed out session and a check for HTTP_REFERER from the second web site, and that works.

    4 replies

    health-pactAuthorCorrect answer
    Inspiring
    August 28, 2008
    Thanks for all of the suggestions. The redirect at the top of each page did not work. The "session timed-out" redirect was apparently happening in application.cfm.

    I have a weird web site which is a web site in wwwroot, with an application.cfm, and another web site in a directory in wwwroot, with a second application.cfm. When I hit the time-out, I was actually being sent back to the application.cfm in wwwroot.

    So, in the wwwroot appl.cfm, I added a check for a timed out session and a check for HTTP_REFERER from the second web site, and that works.
    Inspiring
    August 28, 2008
    put it in your Aplication.cfc/.cfm

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Inspiring
    August 28, 2008
    If the redirection is put inside Aplication.cfc/cfm, once the session times out the user will never be able to get back in. The user will be redirected at every attempt to open a page.
    Inspiring
    August 28, 2008
    If you do not have too many pages, you can put the session check and redirection at the top of each template. If on the other hand you have many pages, it may be advisable to use a custom tag to do the check and redirection.
    Use a session variable that is unique to the user and always exists during the user’s session.

    <cfif not isDefined("session.memberId")>
    <cflocation url="loginPage.cfm" />
    <cfabort />
    </cfif>
    Inspiring
    August 27, 2008
    Can be 2 main places - in a CFTRY/CFCATCH tag surrounding the code, or in teh CFADMIN under SETTINGS where you can have choose "site wide error handlers"