note 46112 deleted from function.session-decode by nlopess

From: Date: Sun, 21 Oct 2007 22:00:00 +0000
Subject: note 46112 deleted from function.session-decode by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-131605@lists.php.net to get a copy of this message
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 :-)

« previous php.notes (#131605) next »