php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11367 changing of current directory to "/" when session is to be saved
Submitted: 2001-06-08 15:55 UTC Modified: 2001-06-14 15:20 UTC
From: alex at gai dot ru Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.0.5 OS: OS/2
Private report: No CVE-ID: None
 [2001-06-08 15:55 UTC] alex at gai dot ru
===cut===
<?php

 function open ($save_path, $session_name) {
    $f = fopen('log', 'a');
    fputs($f, "open ($save_path, $session_name)\n");
    fclose($f);
     return true;
 }

 function close() {
    $f = fopen('log', 'a');
    fputs($f, "close\n");
    fclose($f);
     return true;
 }

 function read ($key) {
    $f = fopen('log', 'a');
    fputs($f, "read ($key)\n");
    fclose($f);
     return "foo|i:1;";
 }

 function write ($key, $val) {
    $f = fopen('log', 'a');
    fputs($f, "write ($key, $val)\n");
    fclose($f);
     return true;
 }

 function destroy ($key) {
    $f = fopen('log', 'a');
    fputs($f, "destroy($key)\n");
    fclose($f);
     return true;
 }

 function gc ($maxlifetime) {
     return true;
 }

 session_set_save_handler ("open", "close", "read", "write", "destroy", "gc");

 session_start();

 $foo++;

 ?>
===cut===
-this will produce one "log" in the document-root directory and another in the root dir.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-14 13:48 UTC] sniper@php.net
This example of yours is bogus. 
1. you should prefix the func names with, e.g. sess_
2. you can't use same file to logging and storing session data. Session file has to be unique for each session.


 [2001-06-14 15:20 UTC] alex at gai dot ru
1. This example is based on the one from PHP Manual.
So, you probably should fix the manual.
2. Originally "sess_" was there. But there was no difference.
3. "log" was made only for loggin'. The basis of the bug is that two(!) log files are created, one in current dir, another in the root, but there is no manual directory changing in my example!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC