Hi! I'm new in PHP and I wanted to know if it's possible to know from where my page has been called?
My company wants to show different information depending if the client accessed the page from google, from another link, typing directly, etc... is there a way to keep track of this?
Thank you so much!!!
Know from where my page was accessed
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: Know from where my page was accessed
Yes it is, but doing so in a reliable way is nearly impossible. You would use the server variable HTTP_REFERER, which can be located in PHP via the $_SERVER array as $_SERVER['HTTP_REFERER']. However, the client's browser must send this variable to your server, and many of your more web-savvy users can block this variable from ever being sent. Anonymity on the internet is desirable, so many users will do this, myself included. So, you will have requests from other websites that will seem as if they accessed your website directly.
If you want to know where users are navigating from within your own website, you could place the location into the url in the query string. For example, on your Contact page, every link could have the query string, "?ref=contact", tacked to the end of them.
If you want to know where users are navigating from within your own website, you could place the location into the url in the query string. For example, on your Contact page, every link could have the query string, "?ref=contact", tacked to the end of them.
Re: Know from where my page was accessed
thank you so much! I'll some research on the matter 
Thanks!!!
Thanks!!!