Bug #73616 [NEW]: session file read warning when using custom DB session handler
| From: | jfoster at cervistech dot com | Date: | Sun, 27 Nov 2016 23:05:14 +0000 |
| Subject: | Bug #73616 [NEW]: session file read warning when using custom DB session handler | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-205665@lists.php.net to get a copy of this message | ||
From: jfoster at cervistech dot com
Operating system:
PHP version: 7.1.0RC6
Package: Session related
Bug Type: Bug
Bug description:session file read warning when using custom DB session handler
Description:
------------
When using session_set_save_handler to implement a custom database based
session handler, PHP is throwing the following warning on
session_start():
PHP Warning: session_start(): Failed to read session data: user (path:
C:\PHP\session\)
The session handler is functioning correctly and reading/writing
correctly to the DB, but is throwing the warning when no files are being
used for sessions.
This same code has functioned without throwing the warning for every
version of PHP since PHP 5.4. The warning only started occurring in 7.1
Test script:
---------------
$sess = new SessionManager();
session_start();
class SessionManager
{
var $life_time;
#function SessionManager()
function __construct()
{
// Read the maxlifetime setting from PHP
$this->life_time = get_cfg_var("session.gc_maxlifetime");
// Register this object as the session handler
session_set_save_handler(
array($this, "_open"),
array($this, "_close"),
array($this, "_read"),
array($this, "_write"),
array($this, "_destroy"),
array($this, "_gc")
);
}
function _open()
{
return true;
}
function _close()
{
return true;
}
function _read($id)
{
//code to read session data from db based on $id
}
function _write($id, $data)
{
//code to write/update session data to db based on $id
return TRUE;
}
function _destroy($id)
{
//code to delete session data from db based on $id
return TRUE;
}
function _gc()
{
//code to delete session data from db based on timestamp
return true;
}
}
Expected result:
----------------
Session handler to process session without throwing read file warning
Actual result:
--------------
Session handler processes session data from db successfully, but throws
file read error.
--
Edit bug report at https://bugs.php.net/bug.php?id=73616&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73616&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73616&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73616&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73616&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73616&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73616&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73616&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73616&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73616&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73616&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73616&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73616&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73616&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73616&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73616&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73616&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73616&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73616&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73616&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73616&r=mysqlcfg