unserialize()'ing session data

From: Date: Mon, 05 Aug 2002 21:17:40 +0000
Subject: unserialize()'ing session data
Groups: php.general 
Request: Send a blank email to php-general+get-111278@lists.php.net to get a copy of this message
Good day, I was writting a user-level storage function for my sessions using: session_set_save_handler (). I'm just storing them in a MySQL db instead of in flat files. My sessions work perfectly and the site continues to function normally. I want to pull the serialized() data from the db and use it outside of the session application. Basically, I want to be able to have a 'watchdog' script that shows an admin what all his users are doing on the site (so I'd store all data in the session variable as they navigate the site). When I try to unserialize() the data I always get 'unserialize() failed at offset 0'. If I echo my serialize()'d $_SESSION variable to browser as I navigate my site, the string doesn't match what is stored in the db, or in the flat files (I tried both). So it makes sense that unserialize() fails because it looks like what's in stored by the session system isn't the same as what would be created by serialize(). They are very similiar, however, the only difference is that the serialized string in the db/files has pipe's (|) in it. Would you mind taking a momment to direct me to a page with the answer (I can't find it anywhere) or explain what they represent? Are they operators? Do I need to preprocess this string before I unserialize it? Any help here would be greatly appreciated. If I take out the 'xxxx|' from the 'xxxx|restofserializedstring' then unserialize will, in fact, work. Well, it doesn't fail that is, but I doubt the result is exactly what I'm expecting. Thanks for your time, RJ

« previous php.general (#111278) next »