troubleshooting Question

How can i determine when a session has expired?

Avatar of paddycobbett
paddycobbett asked on
ColdFusion Language
14 Comments2 Solutions1257 ViewsLast Modified:
I need to work out how to determine when a session has expired/timed out. In my application.cfm i declare session management (as attached in the code sample). I presume that all data associated with a SESSION is destroyed when the SESSION timeouts. However, the problem is that the session puts some data in the application scope which i would like to destroy when the SESSION timeouts also, so i need to detect when this occurs. Or to give another reason, i'd like the user to be displayed a reason for being "logged out", i.e. "Please sign in again as your session has expired", rather than just being told to "sign in", right now the system can't distinguish between the 2 cases.

So all i really need to know is how can i determine when a SESSION has timed out? I'm aware of application.CFC, which has a onSessionEnd() (or something like that), however i've had problems using cfajaxproxy with application.CFC, so have remained with application.CFM (this also appeared to not be an uncommon problem having looked on blogs). Either way, the application.cfc is a new inclusion to coldfusion, so what did people do previously to detect the end of a session?

Additionally, i noticed (and correct me if i'm wrong), that the session time out is fixed, i.e. it's not related to "idle time". Is there a built in way to specify an "idle timeout". Or if there's a way to extend the timeout, which i could do by adding a few minutes after each page click (inserting some code in the header of each page for example).

Thanks in advance.
<CFAPPLICATION 	name="myapp" 
	sessiontimeout="#CreateTimeSpan(0, 3, 0, 0)#">

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 2 Answers and 14 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 2 Answers and 14 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004