计算我的网站访问者访问我网站的确切时间。 [英] calculate the exact duration for which the visitor of my website has visited my website.

查看:77
本文介绍了计算我的网站访问者访问我网站的确切时间。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以知道如何计算访问者访问我的网站的持续时间



timeduration?



我的网站上没有会话,因为它不是用户特定的网站

can any one give idea how to calculate time duration for the visitor visit my website

timeduration?

there is no session on my website because it is not an user specific website

推荐答案

嗯......在实践中你不能准确,即使你强迫他们登录和退出。



没有什么可以告诉你的服务器这个用户已经离开了这个页面(更不用说这个用户已经停止了阅读本页并正在查看新闻) - 特别是如果你没有会话提供可靠的使用结束指示器。



那里是在javascript中检测页面关闭的方法 - 但它们并不总是有效 - 并且没有会话就没有办法将它们与用户开始阅读它的日期和时间联系起来。如果没有别的,同一个路由器上的所有用户都获得相同的IP地址,所以如果你有两个用户,你就不知道关闭页面的用户何时打开它。



你认为自己需要做什么?可能有更好的解决方案。
Um...in practice you can't be accurate, even if you force them to log in and out.

There is nothing that tells your server "this user has moved away from this page" (much less "this user has stopped reading this page and is looking at the news instead") - particularly if you don't have a Session to provide a solid "end of use" indicator.

There are ways to detect that a page is closed in javascript - but they don't always work - and without a session there is no way to tie even them to the date and time that the user started reading it. If nothing else, all users on the same router get the same IP address, so if you have two users, you don't know when the user closing the page opened it.

What are you trying to do that you think you need this? There may be a better solution.


您可以做的最好是在每个页面上检查用户是否有您定义的cookie,如果没有创建具有当前date.\\time的cookie 。如果您读取此cookie的值并从当前日期时间中减去该值,那么这将让您知道他们在该请求时已经在您的网站上停留了多长时间。



您不知道用户何时关闭浏览器或导航离开您的网站,并且您无法根据此数据将内容推送到客户端,因此对您来说可能毫无用处。
Best you could do is that on every page check if the user has a cookie you define, and if not create one that has the current date\time. If you read the value of this cookie and subtract it from the current datetime then that'll let you know how long they've been on your site at the point of that request.

You don't know when the user is closing their browser or navigating away from your site and you can't "push" content to the client based on this data either so it's probably useless to you.


这篇关于计算我的网站访问者访问我网站的确切时间。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆