I am having an issue with setting a session called referrer to a value. What I am trying to do is if someone comes to the site, set the page they came from in a session so I can use it if they submit a form later to tell where they came from originally. I only want to do this the first time they come to a page and don't want it to change as they browse the site. The problem is that when I try it like this it is saving the javascript as the session so it changes on every page cause the session is equal to the javascript and not the value written out by the javascript. Any help would be greatly appreciated.
PHP Code:
<?php
if(isset($_SESSION['referrer']))
{}
else
{
$_SESSION['referrer'] = '<script>document.write(document.referrer);</script>';
}
echo $_SESSION['referrer'];
?>
Comment