Edit report at https://bugs.php.net/bug.php?id=68015&edit=1
ID: 68015
User updated by: rmoisto at gmail dot com
Reported by: rmoisto at gmail dot com
Summary: Session is not filled in cli script
Status: Not a bug
Type: Bug
Package: Session related
Operating System: Ubuntu 12 x64
PHP Version: 5.5.16
Assigned To: yohgaki
Block user comment: N
Private report: N
New Comment:
I was testing this issue with PHP 7 beta.
What I found was PHP is checking for the owner of the session file. Obviously the reader/writer of
the file will be different for cli and fpm, therefore the issue.
Why is PHP doing this? File permissions don't even matter which makes no sense.
So I'm guessing all I need to do in order for a workaround is figure out how to start my
scripts as www-data.
On closer inspection the issue might be only with root user. My script is failing when I start it
with root every time except when the session file is owned by root.
Previous Comments:
------------------------------------------------------------------------
[2015-05-24 16:06:42] rmoisto at gmail dot com
I have
session.use_strict_mode = 0
in both cli and fpm versions of php.ini
I haven't touched it, it's the default value.
Tried my test code again and no luck. Tried changing 0 to Off but still the same.
------------------------------------------------------------------------
[2015-05-24 06:28:03] yohgaki@php.net
I think you have use_strict_mode = On in you php.ini
Look for "php -i" output if it is disabled.
session.use_strict_mode => Off => Off
Unless you disable it, new session ID is always created and used, rather than supplied session ID.
Feel free to reopen is you have issue with use_strict_mode=Off.
------------------------------------------------------------------------
[2015-02-15 04:22:22] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
------------------------------------------------------------------------
[2015-02-03 21:17:43] rmoisto at gmail dot com
The problem is still present.
Output of "php -v":
PHP 5.5.18-1+deb.sury.org~precise+1 (cli) (built: Oct 17 2014 15:11:34)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
I've updated my test script:
<?php
session_id($argv[1]);
session_start();
echo file_get_contents('/var/lib/php5/sessions/sess_' . $argv[1]) . PHP_EOL;
var_dump($_SESSION);
var_dump(session_id());
var_dump(session_save_path());
Which outputs:
(actual data in the session file, too much of it to paste here)
array(0) {
}
string(26) "l8lrlpo9t36guik6m8h04lnaa6"
string(22) "/var/lib/php5/sessions"
The assumption that a CLI script is filling the session is false.
It is filled by fpm that is used by the web server (nginx).
------------------------------------------------------------------------
[2015-02-03 03:43:34] yohgaki@php.net
It seems working now. Do you still have this issue?
[yohgaki@dev PHP-5.5]$ cat t1.php
<?php
session_id($argv[1]);
session_start();
var_dump($_SESSION);
$_SESSION['test']=time();
[yohgaki@dev PHP-5.5]$ ./php-bin -d session.use_strice_mode=0 t1.php 21345
array(1) {
["test"]=>
int(1422934949)
}
[yohgaki@dev PHP-5.5]$ ./php-bin -d session.use_strice_mode=0 t1.php 21345
array(1) {
["test"]=>
int(1422934964)
}
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=68015
--
Edit this bug report at https://bugs.php.net/bug.php?id=68015&edit=1