Using cookies and JavaScript to create a page to page timer.
I have long wanted to be able to measure the time it takes to get from one page to another. While reading in my JavaScript reference the other day, I came across cookies. I've long known about cookies but have never used them. The thing that looked attractive was that you can access cookies from both JavaScript and CF.
So I put together the procedures to store the "start time" (startTimeP8D) for the transition and activated it on the onUnload event of a 1stpage. After a few rewrites I got it working. Here is the JavaScript to do that: it consists of two functions: doTimer which is the input section and setCookie, which writes to the cookie. Not the two numbered alert statements.


doTimer - results for "start" from the doTimer function called from page 1 when it unloads. (See doTimer below)


Please note that the two startTime8D values are the same immediately after they are stored.
On the 2nd page in the sequence, I run the corresponding code to determine the "end time", compute the delta and write it out to the page. It didn't all run on the first try, but it now seems to be running without a crash, which can be misleading.
second set of outputs from page 2:


Please not that while the endTimeP8D match, the startTimeP8D value no longer matches the previously stored value.
There is one major hitch in the get along which has me stymied: As you can see, when you compare the startTimeP8 in the setCookie – results above and the "startTimeP8" in the doTimer results below the startTimeP8 is not the value that I wrote to the cookie @ unload of page 1. I have checked and checked and do now see anywhere that the startTimeP8D value is being overwritten. Based upon my limited experience with JavaScript cookies, it seems to me that you get an entry for each time you set the cookie. So I would expect to see to startTimeP8D entry for each setCookie event, not a different value.
The result of the failed computation is shown on the bottom of the page. As you can see, the Total Elapsed Time is negative, which is never a good sign. The other time shown, Page build time, is the run time from the server. The whole purpose is to be able to show folks that the reason the code might be show is because of their overloaded network and not our code. We had one client whose had users running on 56k modems. It was so slow their VPN software was timing out!!! Still the had the never to blame us!!!

I am using SQLServer 2005, CF8, IE8 on W7.
I'm not married to this way of doing this so if anyone has a better/easier way of doing a "page to page timer", I'm up for it. I'd prefer to fix this one since I've been working on it for the past 3 days.
Thanks in advcance for your help.
:-}
Len, PHRED SE
.
