How do I keep session state of a variable throughout a site?
For example:
A user lands on my website, the string generated is
$string = 'uejsh37rhda283jde86541as';
(This string is autogenerated by an xml feed on every page refresh).
Now, everything works so far ok. The problem is when the user clicks on another page on the site, the xml feed creates a new random string.
I know I have to use sessions here, but how exactly?
if(isset($_SESSION[])):
?
else:
?
endif;
Updated code:
if(isset($_SESSION['session'])):
$string = $_SESSION['session'];
else:
$string = $sessionId;
$_SESSION['session'] = $string;
endif;
echo $string;