List Info

Thread: note 46112 deleted from function.session-decode by nlopess




note 46112 deleted from function.session-decode by nlopess
user name
2007-10-21 17:00:00
Note Submitter: luc at lucje dot removethisforspamplease dot
nl 

----

I also wanted to read stores PHP sessions.
Here's my code:

function unserializesession($data) {
	$vars=preg_split('/([a-z,A-Z]+)|/',$data,-1,PREG_SPLIT_NO_
EMPTY | PREG_SPLIT_DELIM_CAPTURE);
	for($i=0; $vars[$i]; $i++) {
		$result[$vars[$i++]]=unserialize($vars[$i]);
	}
	return $result;
}

// this is just for the example
$session='/tmp/sess_'.$PHPSESSID;
// Why isn't there a sfile() function that returns a file as
a string?
$h=fopen($session,'r');
$data=fread($h,filesize($h));
fclose($h);

$data=unserializesession($data);

Voila. It does the trick for me 

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )