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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to catch session variable expiration CF4.5

Status
Not open for further replies.

IMLee

Programmer
Nov 8, 2000
9
0
0
US
Hello,

I am trying to catch the expiration of session variables in a Cold Fusion 4.5 application.

Does anyone know where examples, samples or code snippets on this subject can be found. I have looked in the most recent Que and Sybex books without success.

Any help or advice would be most appreciated.

Thanks

IMLEE
 
There are various ways of doing this. This is how I usually catch it...

Code:
<CFIF ISDEFINED(&quot;session.myvariable&quot;)>

   ... page code

<CFELSE>
   
   Session Expired.  Please Relog in..

</CFIF>

In CF Administrator, you can specify how long you want your sessions to last. You can also do this in APPLICATION.CFM.

Is this what you mean?
 
Thanks for your response.

The method you cite works but not if the user has left the site. I am trying to have an event handler triggered when a client session variable expires.

In this way clean up of other session associated resources can be accomplished, even if the user has surfed off the site.

We have been able to trap leaving the site with a top.onUnload event handler in javascript. The problem with this is that redirecting on this event loses the user's destination.

Thanks for your help. If you have any further thoughts, I would be grateful to hear them.

IMLEE

 
There is no way to know whether or not your session variable has cut off via event handeling. ColdFusion doesnt even know the variable exists until the client attempts to contact the server. There is, however, a way using JavaScript to do it. You can create another session variable that is equal to the time the first session variable was set. Then, using javascript, you can count the minutes utill the time limit wears out in the status bar. Each time the page is loaded, the variable will stay the same and will still be processed by the JavaScript cross-page load without any transfering of info between forms or QueryString. THe JavaScript will countdown on each page until time is up. This way, the user can keep track of how much time they have left before they have to log back in.
 
Rafajafar,

Thanks very much for your advice. I will try to implement this as you describe.

I will contact you again to let you know how it went.

Thanks again.

IMLEE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top