bpurcell.org - Keeping a session alive on ColdFusion using Jquery
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Subject Archives
Amazon EC2 (15)
ColdFusionMX (155)
Corvette (3)
Flash Lite (4)
Flash Media Server (5)
Flash Player (3)
Flex (39)
General Web Dev (14)
HDTV (3)
Jboss (1)
Jquery (2)
JRun (59)
Max 2003 (3)
Other (33)
PC Hardware (16)
Software (17)
SpatialKey (7)
Wireless (8)
Working Out (1)

RSS Feed
Feed Listing

Site Contents
My Blog
Wireless & Networking
Hardware & Gadgets
Software Picks
Contact Me

My Articles & Papers
Flex Performance
mm.com Under the Hood
Multiple Instances of CFMX
Multiple Instance Config
NLB with ColdFusion
Clustering CFMX for J2EE
Multi-Tier Hardware LB w CFMX
Cisco CSS & Coldfusion MX
JRun 4 Jini based Clustering
WiFi Growth

2ID Tacweb

Other Hobbys
Body-For-Life Challenge

Personal Projects
Family Pool
Deck Gate


Viewing Individual Entry / Main
August 4, 2009

There is nothing more frustrating than taking 30 minutes filling out some text in a long form only to submit and have your session reset and lose all of your data. Here is a simple solution to keep a session open on forms where users may need an extended period of time for data entry. I included this code on any page where I need the session extended. You can remove the javascript include if JQuery is included on everyone of your pages already.

<!--- Include this file on any page where users may take a 
long time filling in text and you want to keep the session open --->
<cfparam name="variables.refreshrate" default="60000">
<script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
<script language="JavaScript" type="text/javascript">
 	function callserver()
var remoteURL = '/emptypage.cfm	';
    $.get(remoteURL,  function(data){


Nice! I wonder about setting it up to execute on key strokes so it would really be a timeout based on user activity sans server interaction. Not sure about getting a page on every key stroke, that might be a little crazy. maybe some hybrid

You can shorten that quite a bit by using:

$(document).ready(function(){ window.iCallServerId = setInterval(function (){ var remoteURL = '/emptypage.cfm '; $.get(remoteURL); }, #variables.refreshrate#); }

If you ever need to "stop" the refreshing, you could just call clearInterval(window.iCallServerId).

Page Render Time:203