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

前端 未结 3 1223
抹茶落季
抹茶落季 2021-01-02 23:15

simple question:

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

and

how to find the locati         


        
相关标签:
3条回答
  • 2021-01-02 23:49

    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)

    0 讨论(0)
  • 2021-01-02 23:50

    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.

    0 讨论(0)
  • 2021-01-02 23:51

    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.

    0 讨论(0)
提交回复
热议问题