change this... that tells a user who has been inactive for the last 19 minutes that
their session (assuming it's set to timeout at 20 minutes in cfapplication) will
expire in 60 seconds, and invites them to reactivate their session by clicking on the
OK button in the JS message box. Clicking OK pops up a self closing window, which does
the actual reactivating.
Just cfinclude it on a template that always is present when a session is active, or
from within application in a "if IsDefined('session.mySessionFlag')" block.
This isn't actually related directly to whatever timing mechanism is used to expire
the session within the server, but runs parallel using _javascript_ on the client
browser. Adapt as you need.
<cfif IsDefined("url.sessionwatch")>
<html>
<head><title></title></head>
<body>
<table width="100%"><tr><td align="center"><form>
Session extended.<br>
<input type="submit" value="OK">
</form></td></tr>
</table>
<script>
window.close();
</script>
</body></html>
<cfabort>
</cfif>
<cfparam name="attributes.launchTime" default="19">
<cfoutput>
<cfset thisLaunchTime = (attributes.launchTime * 60 * 1000)>
<script language="_javascript_">
function watchSession() {
timerID = setTimeout("refreshSession()", #thisLaunchTime#);
}
function refreshSession() {
if (confirm("Your session will timeout in 60 seconds. Would you like to extend the
session?")) {
serverCall =
window.open(document.location.href.split("?")[0]+"?sessionwatch=1&<cfif
IsDefined("URLTOKEN")>#URLToken#</cfif>", "RefreshSession", "width=150, height=50");
watchSession();
}
}
watchSession();
</script>
</cfoutput>
-----Original Message-----
From: Jim McAtee [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 10, 2004 11:03 PM
To: CF-Talk
Subject: How to tell if a session has expired?
Is there a means of determining if a CF session has timed out? For instance,
in the context of a shopping cart application. I've seen applications on
other sites where you get a message to the effect of "Your session has
expired" rather than just a "Your shopping cart is empty". I'm trying to
figure out how to do this.
I can check to see if certain session variables exist, but can't think of a
way to tell whether they were never set or if they existed at one time and
have now "gone away" due to the session expiring.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

