php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #39619 custom session save handler looses current directory
Submitted: 2006-11-24 14:59 UTC Modified: 2007-08-17 11:37 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: thbley at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.0 OS: WinXP SP2
Private report: No CVE-ID: None
 [2006-11-24 14:59 UTC] thbley at gmail dot com
Description:
------------
I'm using a custom session save handler. When the write function is called, the current directory is changed to the apache bin directory. This breaks when using relative paths for storing session data.

Reproduce code:
---------------
session_set_save_handler("none","none","read","write","none","none");
session_start();
  
echo "2 ".getcwd()."<br>";
  
function none() {
  return true;
}

function read($id) {
  echo "1 ".getcwd()."<br>";
}

function write($id,$val) {
  echo "3 ".getcwd()."<br>";
}


Expected result:
----------------
1 H:\sgs\src

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at H:\sgs\src\test_session.php:14) in H:\sgs\src\test_session.php on line 5
2 H:\sgs\src
3 H:\sgs\src

Actual result:
--------------
1 H:\sgs\src

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at H:\sgs\src\test_session.php:14) in H:\sgs\src\test_session.php on line 5
2 H:\sgs\src
3 H:\Development\Apache2_php5\bin

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-24 15:04 UTC] tony2001@php.net
Please add session_write_close() to the end of the script and see if it works for you.
 [2006-11-24 15:13 UTC] thbley at gmail dot com
Yes adding session_write_close() works but this means I need to call it every time I call exit(), die(), return etc. ... not very comfortable for bigger programs.
The documentation doesn't state the directory change, see http://de.php.net/manual/en/function.session-set-save-handler.php
 [2006-11-24 15:20 UTC] tony2001@php.net
The fact that ext/session is affected by shutdown order sequence is a known problem, but unfortunately noone is willing to rewrite ext/session from scratch, which is most likely required to get this problem fixed.
 [2006-11-25 09:49 UTC] thbley at gmail dot com
So can you update the documentation on http://www.php.net/manual/en/function.session-set-save-handler.php ? I think this would save the people a lot of time if they know that they have to use absolute paths here.
 [2007-08-17 11:37 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Current working directory is changed with some SAPIs if session is closed in the script termination. It is possible to close the session earlier with session_write_close()."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 08 14:01:33 2025 UTC