Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session timeout redirection custom page

Status
Not open for further replies.

shukui

Technical User
Apr 27, 2001
28
US
Hi there,

Could anyone tell me how can I redirect a user to a customed page (such as a login page) if the session is timeout and the user is trying continue a page. Help please.

sguan
 
Hi,

I usually put this in application.cfm but it can just as easily be put at the beggining of each file.

<CFLOCK TIMEOUT=&quot;120&quot; NAME=&quot;#Session.SessionID#&quot;>
<CFIF #ParameterExists(Session.Name)#>
<CFSET Name = &quot;#Session.Name#&quot;>
<CFSET ID = #Session.ID# >
<CFELSE>
<CFLOCATION URL=&quot;login.cfm&quot; Addtoken=&quot;no&quot;>
</CFIF>
</CFLOCK>

The Session variables that you use are arbitrary, just as long as you have one or more set, you can test if it exists. If it does then the session hasn't expired. If the variable does not exist then the session has expired and this will re-direct the user to the login.cfm page.
 
Thanks thawkins, that does the trick perfectly. Have a great day!

sguan
happy.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top