Bug #77588 [Opn->Fbk]: Session started with read_and_close creates empty session

From: Date: Sat, 09 Feb 2019 00:40:48 +0000
Subject: Bug #77588 [Opn->Fbk]: Session started with read_and_close creates empty session
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219453@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77588&edit=1 ID: 77588 Updated by: yohgaki@php.net Reported by: piotr at halas dot net dot pl Summary: Session started with read_and_close creates empty session -Status: Open +Status: Feedback Type: Bug Package: Session related Operating System: Linux PHP Version: 7.2.15 Block user comment: N Private report: N New Comment: I got this result from my Fedora's PHP 7.2.14. Are you using "files" save handler? I guess not. It looks like I have to document "save handler" authors must create session data (and lock it) upon read when data does not exist yet. ------------------ [yohgaki@dev PHP-master]$ php -v PHP 7.2.14 (cli) (built: Jan 8 2019 09:59:17) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.14, Copyright (c) 1999-2018, by Zend Technologies [yohgaki@dev PHP-master]$ php <?php ini_set('session.save_path', getcwd()); session_start(['read_and_close' => true]); echo "Sessions: ".count(glob(getcwd().'/sess_*')).PHP_EOL; Sessions: 1 Previous Comments: ------------------------------------------------------------------------ [2019-02-08 14:14:07] sjon at hortensius dot net I don't think this is a bug - all read_and_close does is "result in the session being closed immediately after being read" so it doesn't influence session_start from creating an empty session like it always does - see https://3v4l.org/fLnNI ------------------------------------------------------------------------ [2019-02-08 14:02:06] spam2 at rhsoft dot net hell you use a readonly option and ask why it don't write... ------------------------------------------------------------------------ [2019-02-08 13:53:07] piotr at halas dot net dot pl Ini_set is only for test purpose. The problem is that session_start(['read_and_close' => true]) creates new empty session file if no session file is found. This happens also with memcached save_handler. ------------------------------------------------------------------------ [2019-02-08 13:44:54] spam2 at rhsoft dot net what does the ini_set here and are you aware that it is not supposed to init a new session but resume one readonly to watch for example status of file uploads ------------------------------------------------------------------------ [2019-02-08 13:38:58] piotr at halas dot net dot pl Description: ------------ I don't know if this is a bug, but when starting a session with read_and_close options enabled PHP creates an empty session if no session was found. Test script: --------------- <?php ini_set('session.save_path', getcwd()); session_start(['read_and_close' => true]); echo "Sessions: ".count(glob(getcwd().'/sess_*')).PHP_EOL; Expected result: ---------------- Sessions: 0 Actual result: -------------- Sessions: 1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77588&edit=1

« previous php.bugs (#219453) next »