Hi Guys,
I tihnk my other question was a bit vague so...
This is the situation.
I have an xml feed that generates a random 24 character string on every page refresh.
So, when a user visits my site and lands on a page called 'how-to-make-blue-widgets.php' - their unique string is generated as 38jsue710ppahchd67ywha94 for example.
Now, when this user clicks on another page, lets say 'how-to-make-red-widgets.php' - the feed creates a brand new string: 836aeq88udh761aso09kjs21.
What I want to do is store the first value created by the feed throughout the user's visit on every page visited.
I am using sessions and here is my code:
// Start Session
session_start();
...
// Don't worry about this bit - $sessionId is the random string
if($xmlobj = simplexml_load_string(file_get_contents($xml_feed)))
{
$result = $xmlobj->xpath("TrafficMeta");
$sessionId = $result[0]->sessionId;
}
// Main Part
if(isset($_SESSION['sessionString'])): // if 'random' session is set
$string = $_SESSION['sessionString'];
else:
$string = $sessionId;
$_SESSION['sessionString'] = $string;
endif;
echo $_SESSION['sessionString'];
It works fine when I first visit the site, the script spits out the session string, but when I refresh, it outputs nothing.
Any ideas?