Quote:
Originally Posted by jmcnulty
ok it's definitely getting closer. Here is my hopeful final issue.
just like you had mentioned embed this code at the very top of my primary page:
CODE A
PHP Code:
<?php session_start(); if (!isset($_SESSION['phonenumber'])) { $ref = getenv('HTTP_REFERER'); if (strpos($ref, "localprice.com") !== false)
{
$_SESSION['phonenumber'] = '888-540-9909';
}
else
{
$_SESSION['phonenumber'] = '888-646-0860';
}
}
?>
Then call upon it somewhere on the page:
CODE B
PHP Code:
<?php session_start(); printf('<span class="phonenumbertext">%s</span>', $_SESSION['phonenumber']);?>
This works absolutely perfectly.
My issue now is - when navigating away from this page into my internal page - I have different header files - so when I use (Code B) it doesn't know what it is referencing.
On the flip side if I try to embed the first block of code (Code A) onto the other header files but this does not work because all traffic is coming through the home page - so the referring page is my own domain, the home page.
Is there a way I can put some code similiar to (Code A) on my internal pages that says 'ignore my own domain as the referer'
I apologize for the complete hassle with this but it's honestly just going over my head.
It's so very very close.
|
session_start() has to be added to any script that intends to use it. It was pointed out not long ago to me that calling it multiple times will raise a notice, so simply put it in a global script to prevent inclusion conflict. So long as sessions are being passed, it shouldn't attempt to extract it again. It does also mean that if a client leaves your site, then comes back through a different route, the number won't change if it was done in less than about 1440 seconds and the garbage collector grabs the session.
You can detect your site using $_SERVER['SERVER_NAME']. That could be useful to see if the referrer has changed.