Session Timer
am 14.02.2005 13:17:01 von tom
Hi everyone,
I want to try and capture the amount of time a user spends on a
particular page. I can figure out what time they first viewed a page,
but is there a simple way to update an Access DB when the page closes
or they navigate away from the page?
Thanks in advance,
Tom
Re: Session Timer
am 14.02.2005 15:08:46 von reb01501
Tom Jordan wrote:
> Hi everyone,
>
> I want to try and capture the amount of time a user spends on a
> particular page. I can figure out what time they first viewed a page,
> but is there a simple way to update an Access DB when the page closes
> or they navigate away from the page?
>
Nothing that can be done via ASP server-side code. You can get close using
client-side code (using the onunload event) but even that will not be
foolproof. Post your question to a client-side newsgroup, such as
..scripting.jscript, and ask about using XMLHTTP to call server-side pages
from client-side code (you may wish to try Google before posting your
question - this has been discussed many times).
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Re: Session Timer
am 17.02.2005 15:10:07 von TB
I am total newbie to these issues, but wouldn't it be possible to do it the
ASP way like this??:
On page 1 (login page):
<%
(you establish your DB connection and Recordset (RS) including "User" and
check credentials. If everything is OK, then:)
response.write "Welcome " & RS("User") & "
"
Session("timein") = now()
Session("user") = RS("user")
RS.close
Conn.close
Set RS = nothing
Set Conn = nothing
%>
to continue
on test2.asp
<%
(You establish your DB connection)
dim strSQL, timein, timeout, timespent, user
timein = Session("timein")
user = Session("user")
while Response.IsClientConnected
(all the stuff that happens on this page)
wend
timeout = now()
timespent = timein - timeout
StrSQL = "UPDATE users set timespent = " & timespent & " WHERE user = '" &
user & "'
conn.Execute strSQL, adAffectAll, adCmdText Or adExecuteNoRecords
conn.Close
Set conn = Nothing
%>
I don't know really. Might it work??
TB
"Bob Barrows [MVP]" wrote in message
news:u9xz26pEFHA.3992@tk2msftngp13.phx.gbl...
> Tom Jordan wrote:
>> Hi everyone,
>>
>> I want to try and capture the amount of time a user spends on a
>> particular page. I can figure out what time they first viewed a page,
>> but is there a simple way to update an Access DB when the page closes
>> or they navigate away from the page?
>>
> Nothing that can be done via ASP server-side code. You can get close using
> client-side code (using the onunload event) but even that will not be
> foolproof. Post your question to a client-side newsgroup, such as
> .scripting.jscript, and ask about using XMLHTTP to call server-side pages
> from client-side code (you may wish to try Google before posting your
> question - this has been discussed many times).
>
> Bob Barrows
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>