|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-02-08 13:38 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 22:00:01 2025 UTC |
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