tivrfoa Posted December 9, 2008 Share Posted December 9, 2008 Is it possible to know the site the user was before visit my site? thks Link to comment https://forums.phpfreaks.com/topic/136215-solved-get-the-site-the-user-was-before/ Share on other sites More sharing options...
Adam Posted December 9, 2008 Share Posted December 9, 2008 $_SERVER['HTTP_REFERER']; A Link to comment https://forums.phpfreaks.com/topic/136215-solved-get-the-site-the-user-was-before/#findComment-710537 Share on other sites More sharing options...
PFMaBiSmAd Posted December 9, 2008 Share Posted December 9, 2008 The only information you receive is what the browser provides when it requests a page on your site. The HTTP_REFERER header is intended for this purpose. However, browsers don't always provide this under all situations, it can be turned off, and it can be faked (most web proxies set it to be the same as the domain being requested.) So, while you can log the HTTP_REFERER for informational purposes, you cannot really rely on it for any functional use. Link to comment https://forums.phpfreaks.com/topic/136215-solved-get-the-site-the-user-was-before/#findComment-710542 Share on other sites More sharing options...
tivrfoa Posted December 9, 2008 Author Share Posted December 9, 2008 thank you MrAdam and PFMaBiSmAd! PFMaBiSmAd ... just for informational purposes But I think I can use it, because the page that I'll verify is in the same domain. $last_page = $_SERVER['HTTP_REFERER']; if($last_page == 'http://www.mydomain.com/page1.php') { echo 'Ok. You may pass'; } else { header('Location: http://www.google.com?msg=get out of here'); die(); } what do you think? Link to comment https://forums.phpfreaks.com/topic/136215-solved-get-the-site-the-user-was-before/#findComment-710586 Share on other sites More sharing options...
PFMaBiSmAd Posted December 9, 2008 Share Posted December 9, 2008 You asked about the site someone was on before you site. If you need to check if someone was on a specific page on your site before they get to a different page on your site, then you need to use sessions and set a session variable that says they were on the first page and then check this on the second page. Link to comment https://forums.phpfreaks.com/topic/136215-solved-get-the-site-the-user-was-before/#findComment-710595 Share on other sites More sharing options...
tivrfoa Posted December 9, 2008 Author Share Posted December 9, 2008 You asked about the site someone was on before you site. If you need to check if someone was on a specific page on your site before they get to a different page on your site, then you need to use sessions and set a session variable that says they were on the first page and then check this on the second page. session is a good solution. But I'm using moodle, and session here sometimes work strange, so I'm avoiding it. but do you think the condition I showed before will work? Link to comment https://forums.phpfreaks.com/topic/136215-solved-get-the-site-the-user-was-before/#findComment-710628 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.