Note Submitter: jon at jonroig dot -----com
----
This code is to solve a problem that's probably becoming more common as we move into the AJAX world -- how the &*^*&^ to access session data if you're transferring data back 'n' forth from a server and you don't have cookies to help you out.
The function accepts the session ID then grabs the session data straight from the directory, parses it, and returns it as an array.
<?
function grabSessionData($sessionInput)
{
$sessionThing = "/tmp/sess_".$sessionInput;
$textContentsArray = file($sessionThing);
$serializedData = '';
foreach ($textContentsArray as $line => $textLine)
{
$serializedData = $serializedData.$textLine;
}
$sessionArray = explode(";",$serializedData);
$sessionDataArray = array();
foreach ($sessionArray as $line => $dataLine)
{
$dataArray2 = explode('|',$dataLine);
$dataArray3 = explode(':',$dataLine);
$sessionDataArray[$dataArray2[0]] =
str_replace('"','',$dataArray3[count($dataArray3)-1]);
}
return $sessionDataArray;
}
// example
$sessionInfoArray = grabSessionData('f58c92b76c1dd553c56dd428ea7a1bfc');
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.