php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63963 Session save does not always happen.
Submitted: 2013-01-10 23:56 UTC Modified: 2013-06-04 21:25 UTC
Votes:5
Avg. Score:4.6 ± 0.8
Reproduced:5 of 5 (100.0%)
Same Version:1 (20.0%)
Same OS:0 (0.0%)
From: jkm9000+php at gmail dot com Assigned: arpad (profile)
Status: Not a bug Package: Session related
PHP Version: 5.4.10 OS: OSX/Linux
Private report: No CVE-ID: None
 [2013-01-10 23:56 UTC] jkm9000+php at gmail dot com
Description:
------------
There is an issue open in the Symfony codebase that seems to actually be a problem 
with PHP. 

https://github.com/symfony/symfony/issues/6417#issuecomment-11878369

I was encouraged to open a ticket here and let Arpad know, but I don't see a way 
to do that here.

Basically when anything other than the default filesystem sessions are used I have 
a reproducible way where session data is lost. When I use the filesytem sessions 
with the same code, it works.

Originally I tried with 5.4.10 via apache / mod_php. The problem persists with 
5.4.10 under nginx/php-fpm.

Test script:
---------------
There is some code mention here - https://github.com/symfony/symfony/issues/6417#issuecomment-11878369

as well as where I opened my ticket originally - https://github.com/FriendsOfSymfony/FOSUserBundle/issues/921

Expected result:
----------------
The expected result would be the session data is present.

Actual result:
--------------
Session data is lost.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-11 00:01 UTC] jkm9000+php at gmail dot com
Sorry, originally tried with 5.4.4 and apache.
 [2013-01-11 06:16 UTC] arpad@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: arpad
 [2013-01-21 19:46 UTC] drak@php.net
It's been reported that calling session_write_close() before the  
fastcgi_finish_request(); call fixes it. Seems like a PHP bug. Reference: 
https://github.com/symfony/symfony/issues/6417#issuecomment-12513993
 [2013-06-04 20:48 UTC] arpad@php.net
-Status: Assigned +Status: Not a bug
 [2013-06-04 20:48 UTC] arpad@php.net
The issue is that fastcgi_finish_request() doesn't try to finish the session for that request, therefore the session isn't written until the (presumably long running) request is actually finished.

I think this behaviour is correct.

If you want to finish the session before this point, you can as Drak noted call session_write_close() explicitly.
 [2013-06-04 21:17 UTC] jkm9000+ph at gmail dot com
Why would this happen when using apache and mod_php though? That was the original 
environment it happened under.
 [2013-06-04 21:25 UTC] arpad@php.net
It's the same lack of writing the session before deciding the request is done.

Also added to the Symfony bug report:

Another thing to note is that object oriented session handlers rely on a shutdown function (if session_write_close hasn't been called) because of object dtors which might need the session.
 [2013-06-04 21:35 UTC] jkm9000+php at gmail dot com
Thanks for the clarification
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 01:01:28 2024 UTC