Bug #71070 [NEW]: Custom session handler write method returns false, warning message misleading

From: Date: Wed, 09 Dec 2015 06:53:27 +0000
Subject: Bug #71070 [NEW]: Custom session handler write method returns false, warning message misleading
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197723@lists.php.net to get a copy of this message
From:             claytonsmith at outlook dot com
Operating system: 
PHP version:      Irrelevant
Package:          Session related
Bug Type:         Bug
Bug description:Custom session handler write method returns false, warning message misleading

Description:
------------
When using a custom session handler it will generate a misleading error
message about why the write failed to happen.  It says to verify the
session.save_path is correct but because we are using a custom session
handler, it may never be attempting to write to that directory.

Example of one user running into this problem:
http://stackoverflow.com/questions/34117651/php7-symfony-2-8-failed-to-write-session-data/

It would be better to have a more clear warning message to diagnose why
this occurs.

Test script:
---------------
<?
error_reporting(E_ALL);
ini_set('display_errors', 1);

class TestHandler extends SessionHandler {
    public function write($id, $data) {
        // Write somewhere that is not a file
        return false;
    }
}

$saveHandler = new TestHandler();
session_set_save_handler(
	array(&$saveHandler, 'open'),
	array(&$saveHandler, 'close'),
	array(&$saveHandler, 'read'),
	array(&$saveHandler, 'write'),
	array(&$saveHandler, 'destroy'),
	array(&$saveHandler, 'gc')
);

session_start(); 

$_SESSION['value'] = 123;
var_dump($_SESSION);


Expected result:
----------------
PHP Warning:  Unknown: Failed to write session data using custom session
handler in custom-session-handler.php on line 123



Actual result:
--------------
 Warning: session_write_close(): Failed to write session data (user).
Please verify that the current setting of session.save_path is correct
(/tmp)


-- 
Edit bug report at https://bugs.php.net/bug.php?id=71070&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=71070&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=71070&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=71070&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=71070&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=71070&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=71070&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=71070&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=71070&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=71070&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=71070&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=71070&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=71070&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=71070&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71070&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=71070&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=71070&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=71070&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71070&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=71070&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=71070&r=mysqlcfg



Thread (6 messages)

« previous php.bugs (#197723) next »