php how to find the location where a user came from?

时间秒杀一切 提交于 2019-11-29 22:40:13

问题


simple question:

how to find the location (url) where a user came from before accessing my page?

and

how to find the location (url) where a user goes after exiting my webpage?

any ideas where i should start? thanks


回答1:


In PHP, you can use the $_SERVER['HTTP_REFERER'] to know where the user came from.

There is no mechanism to know where the user is going, unless they clicked a link on your site to leave your page. (If that is the kind of exit that you want to track, you'll need to rely on javascript and implement something like Google Analytics outbound link tracking: http://www.google.com/support/analytics/bin/answer.py?answer=55527)




回答2:


To the first question:

Usually if someone comes to your page via a link or something like this a HTTP referer entry points to the refering page. See rfc2616

Second question:

If you have a link which links to an external page you may notice this by wrapping these links with some script. If someone types in a page by hand you will not be able to determine the location where the user went.




回答3:


If the from page and destination pages are made by you, You can send the source page's url within GET or POST method and grab it in the destination and redirect user back to that url.



来源:https://stackoverflow.com/questions/6795128/php-how-to-find-the-location-where-a-user-came-from

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!