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.
I usually put this in application.cfm but it can just as easily be put at the beggining of each file.
<CFLOCK TIMEOUT="120" NAME="#Session.SessionID#">
<CFIF #ParameterExists(Session.Name)#>
<CFSET Name = "#Session.Name#">
<CFSET ID = #Session.ID# >
<CFELSE>
<CFLOCATION URL="login.cfm" Addtoken="no">
</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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.