| 5 bootstrap.inc | referer_uri() |
| 6 bootstrap.inc | referer_uri() |
Return the URI of the referring page.
2 calls to referer_uri()
File
- includes/
bootstrap.inc, line 825 - Functions that need to be loaded on every Drupal request.
Code
function referer_uri() {
if (isset($_SERVER['HTTP_REFERER'])) {
return $_SERVER['HTTP_REFERER'];
}
}
Login or register to post comments
Comments
How to check your users come from your site or not
Here is a code snippet to check if the user come from your site or not
<?phpglobal $base_url;
if (($referer_uri = referer_uri()) && (preg_match("!^$base_url/!", $referer_uri))) {
// Do your stuff
}
?>
Only works for authenticated users
Thank you for the script. It works great!
But only for authenticated users. I found that when the user is not logged in referer_uri() doesn't return anything.
In fact, $_SERVER['HTTP_REFERER'] doesn't return anything to anonymous users.
Thoughts? Maybe I'm missing something obvious (usually the case).
DW
I tried using this in D7 without success :-(
I wanted to use referer_uri() in a 2-step product order process in Ubercart. Couldn't get it to work for anonymous users. So I stuck with the following snippet and got it to work just fine:
<?php$last_page_visited = $_SERVER['HTTP_REFERER'];
if(preg_match('/order-step1/', $last_page_visited) && preg_match('/cart/', current_path()))
{
drupal_goto($path = 'order-step2');
}
?>