Page 1 of 1

redirect info

Posted: Mon Oct 10, 2005 8:32 am
by sebs
is there a function or a way to find out the page that opened the curent page.I mean if code.php sends you to search.php,in search.php how can I find out that code.php send me here?

Posted: Mon Oct 10, 2005 8:37 am
by Jenk
You can use the $_SERVER['HTTP_REFERER'] but it is bullet proof.

Posted: Mon Oct 10, 2005 8:44 am
by sebs
As it writes in the documentation:'HTTP_REFERER'
"it cannot really be trusted".Is there any other way?

Posted: Mon Oct 10, 2005 8:50 am
by Jenk
If you created the referring page, you can use session files and session file check on the receiving page.

Code: Select all

<?php
session_start();

$_SESSION['REFERER'] = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];

header('Location: receiver.php');

?>
And on the receiving page:

Code: Select all

<?php
session_start();

if ($_SESSION['REFERER'] == 'http://www.yourdomain.com/sending.php') {
  //woo!
} else {
  //boo!
}
?>

Posted: Mon Oct 10, 2005 12:48 pm
by John Cartwright
When people are online on a site of mine, I track their movements by sessionid stored in a database.
Seems like a slack job having to set manually the pages they are on throughout each page..