note 40395 added to function.session-decode
| From: | ned at wgtech dot com | Date: | Tue, 02 Mar 2004 19:42:53 +0000 |
| Subject: | note 40395 added to function.session-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66125@lists.php.net to get a copy of this message | ||
If you expected this function to return an array you are out of luck. This loads the session string
into the current session. This sucks if you are doing something like managing sessions via some
other function via session_set_save_handler(). I wanted to create an admin module that allowed the
administration to browse the current sessions. Well, that session string is UGLY, and session_decode
is utterly useless for this.
Either way here is a beasty pair of functions that returns an array that looks like $_SESSION would
if you were to use session_decode. It should handle most everything, including arrays of any
dimention (including arrays of arrays of arrays etc).
Call the function decodesession() and pass in the session string (the one created by
session_encode). The second function, decodesessionarray(), should not be called directly. It
handles decoding arrays, if any, in the string, and is recursive (it calls itself if an array stores
an array).
It may not be pretty, but it works nicely.
Let me know if you use it or have any thoughts about this. It would be nice to know someone got some
use out of this code!
NOTE: The code is to big to add here. To see it go to:
http://www.evilwalrus.com/viewcode.php?codeEx=553
----
Manual Page -- http://www.php.net/manual/en/function.session-decode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40395
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40395&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40395&report=yes
Search -- http://master.php.net/manage/user-notes.php