PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi, I have a site where I want to log the refer from visitors entering on any page. I will only be actually collecting this information when someone makes a purchase or sends an enquiry.
I presume I will log it by setting a cookie and then when they submit a sale/enquiry the existence of the cookie is checked and info passed on entered into the DB.
When a user has entered a page from an exernal site and then start browsing around, I obviously don't want my internal pages recorded as the referer so would I then use sessions to let other pages know that a referer has been logged?
I'm just a bit lost and and would like to see how anyone else has done it??
Everytime there is a $_SERVER['HTTP_REFERER'] value that does not originate from your site, store it in the $_SESSION['referer']. Now, you'll always know what the last external site was (if their browser actually passes the referer header and if there was an external site).
There isn't really a reliable method, save for a session var of some sort. When I have absolutely needed a page to know that it was requested from my site I put a check in for a session var. If the var is not set send the user to a page within my domain, otherwise show 'em what they wanted.