Jump to content

[SOLVED] Get the site the user was before ...


tivrfoa

Recommended Posts

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.

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?

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.