Last post Aug 19, 2014 08:00 AM by PawanPal
Aug 07, 2014 07:33 AM|demoninside9|LINK
I have a web application. I just need the information that who have visited which form for how long.
I meant that I need whole time (at what time user gets on the form to access it and for how long user access the page and also the time user leave the page.
Aug 07, 2014 07:40 AM|mike4u|LINK
i think u ve to make seperate table for this. use session ..every time when user will login , session counting will increase at that time store that session counting wrt to
specific page of each user and store it.
proceed with this approach.
Aug 07, 2014 08:13 AM|demoninside9|LINK
specific page of each user
Aug 18, 2014 12:13 PM|Afzaal.Ahmad.Zeeshan|LINK
No specific page at all. All you need to do is, when you create the Database table you will create an extra column with the name of "ForUser" where you will store the value of the username.
You can use his method, to store this value inside the database because there is no other way of doing this thing. But that
how? thing I wanted to help here.
Aug 18, 2014 12:24 PM|AidyF|LINK
The web is stateless, neither the browser nor the server have any way of working out any of this information. The best you can do is hacks like having a table with username, page name, time entered and time left, then storing what page the user accesses
and what time on the page_load, and also look for the last page the user accessed (the entry for that user with nothing in the time left column) and update that record to give the current time as the leaving time.
This will kind of work in most situations, but if the user just leaves their browser or shuts it down you have no way of getting any meaningful data for the last page. If you're just looking for a general idea about what people are doing on your site then
just use the likes of google analytics, or web trends, or any other tracking software as they all do these things for you without you having to reinvent a broken wheel.
Aug 19, 2014 06:11 AM|demoninside9|LINK
table with username, page name, time entered and time left, then storing what page the user accesses and what time on the page_load
I already did this.
update that record to give the current time as the leaving time.
how can I get leaving time?
Aug 19, 2014 06:25 AM|AidyF|LINK
You can't get the leaving time. When you get the entry time of one page, you make that the leaving time of the last page
// db has 'user', 'page', 'entry', 'exit', 'time spent'
// user looks at pagea at 1pm, your data is
me, pagea, 1pm, null, null
// user looks at pageb at 1.05pm, your data is
me, pagea, 1pm, 1.05pm, 5m
me, pageb, 1.05pm, null, null
// user looks at pagec at 1.15pm, your data is
me, pagea, 1pm, 1.05pm, 5m
me, pageb, 1.05pm, 1.15pm, 10m
me, pagec, 1.15pm, null, null
// and so on
As you can see, how you handle the final "exit page" is up to you. The page that has an entry time but no exit time can be considered the last page the user visit, or the exit page, but you have no way of knowing how long they looked at it, as the web is
Aug 19, 2014 06:29 AM|demoninside9|LINK
you make that the leaving time of the last page
Aug 19, 2014 07:16 AM|AidyF|LINK
On each page you need to do two updates, one to insert a new record for that page, and one to update the record for the last page. You can work that out by updating a the page for that user where the exit time is null. You need to be careful about things
such as the user coming back the next day...you don't want to log that the user spent 500 hours looking at your page when the reality is that they just visited it a week ago. It is when you get down to the complexities of these edge scenarios that you decide
to not do this at all and just use google analytics.
Aug 19, 2014 08:00 AM|PawanPal|LINK
You can achieve this by creating service and calling it using jquery. You can capture page enter on: $(window).load(); or $(document).ready();
and page exit on: $(window).unload();
You can capture the time of enter and exit using below code:
var currentdate = new Date();
var datetime = currentdate.getDate() + "/"
+ (currentdate.getMonth()+1) + "/"
+ currentdate.getFullYear() + " @ "
+ currentdate.getHours() + ":"
+ currentdate.getMinutes() + ":"
There are many code sample on google for calling web service using jquery; rest table structure is defined above by many others.
Hope it helps you.