Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to calculate the time that a particular person was opening( viewing) a document in my site, please let me know about a way of doing this.

This is what I want to do.
There is a document in my website.
( Here "document" means any kind of document, ex: word,excel,pdf, .ppt, etc )
One person logs into my website.
He opens that doc.
After sometimes he closes that document.

I need to know the time from when he opened it & to when he closed.
That means , in simple,I want to track the time he was viewing my document)

Thanks in advance.
Posted
Comments
Be Yourself 25-May-11 1:04am    
I think there might be a link to your document right??
So you can use the onclick event of that link to call a function that strores the current time of the system.
Sergey Alexandrovich Kryukov 25-May-11 1:23am    
So what? The user can download the document and view it forever.
Please see my answer.
--SA

1 solution

You see, you can only time the duration between HTTP requests.

This is not the case when your user opens a document. What is "open"? The user sends HTTP request, you receive it, start counting time… but after the server has sent the document to the user, and the user can view it forever, no matter what you do. There is no "close" event, and it can not be there. You can artificially create such event and post it back using Ajax, for example, but the user may or may not cooperate. The user can always download the document and use it forever.

You should understand, it a page or any other document is sent back to the client, it's there; you don't have any control of its life time. Now the user decides for how long time it will be kept.

The only duration you can time is the duration of the session, but it's very different from what you want.

—SA
 
Share this answer
 
v7
Comments
[no name] 25-May-11 1:25am    
Good Call SA.
Sergey Alexandrovich Kryukov 25-May-11 1:30am    
Thank you, Ramalinga.

I'm thinking of some limiting functionality. You can set a timer and send confirmation events "I'm still reading" posts back to the server using Ajax. It would do the trick -- if the user cooperates. But the user can always do "save as" or disable scripts, or just download document not opening it and view locally - whatever. My trick would work but it's time-consuming and ultimately -- pretty much useless.

--SA
Sergey Alexandrovich Kryukov 25-May-11 3:47am    
OP commented:

Hello SAKryukov,
Thanks for the valuable reply. But I'm still searching for a possibility to do this while knowing the identified issues.
We can get the "I'm still reading" only when he is connected to internet.

I'm still researching on this. If more ideas / solutions you all have , please let me know.

Thanks.
Sergey Alexandrovich Kryukov 25-May-11 3:51am    
You cannot do anything else. Just don't waste your time.

This is absurd:
"We can get the "I'm still reading" only when he is connected to internet."

If the user is not connected to internet, she/he does not exist for your application. Isn't that obvious? You cannot control anything. My point is: you cannot control (or even time) anything even if the user is connected. You can only time session or some HTTP request. Start from this point.
You can also catch something like window closing, but it won't help much. Look at my first paragraph: you delivered document to the user. Since then -- forget it.

Don't waste your time.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900