From: rhm31 at cam dot ac dot uk
Operating system: Linux
PHP version: 4.4.8
PHP Bug Type: Session related
Bug description: Difficult to unserialize session data in user session save
function
Description:
------------
A custom session handler has a save function, which is given an opaque
piece of session data. No functions are provided to modify this data, even
though this can be useful in some cases.
As a workaround, session_decode and session_encode can be used. However,
there are some problems:
1. BUG:session_start() must be called in the save function; presumably
because in the save handler the session is already closed.
2. HARD TO USE:The functions do not simply take a string and return an
array or vise-versa; instead they work directly on the $_SESSION array.
This means you cannot easily use them for generic purposes.
A function that implements decode_session below could be added to the
standard library, and the existing functions deprecated, since this
function subsumes them.
Also, a similar function for encode_session.
Reproduce code:
---------------
function decode_session($session_string)
{
$current_session=session_encode();
foreach($_SESSION as $key => $value)
{
unset($_SESSION[$key]);
}
session_decode($session_string);
$restored_session = $_SESSION;
foreach ($_SESSION as $key => $value){
unset($_SESSION[$key]);
}
session_decode($current_session);
return $restored_session;
}
Expected result:
----------------
The session_string to be decoded and returned as an array.
Actual result:
--------------
An empty array is returned with no error message when above function is
called from a session save handler.
--
Edit bug report at http://bugs.php.net/?id=43980&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=43980&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=43980&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=43980&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=43980&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43980&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=43980&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43980&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43980&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43980&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43980&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43980&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=43980&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=43980&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43980&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43980&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43980&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43980&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43980&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43980&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43980&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43980&r=mysqlcfg