ID:               47088
 Comment by:       typoon at gmail dot com
 Reported By:      guido_jansen at gmx dot de
 Status:           Open
 Bug Type:         Session related
 Operating System: Win XP
 PHP Version:      5.2.8
 New Comment:

I am unable to reproduce the issue on PHP 5.2.8 (cli) and am unable to
reproduce on PHP 5.3.0alpha4 on both Windows XP and Linux.
Please try the code below and see if you see the issue. Perhaps you
have some code problem there?
In case you still see the issue, please provide more details on how and
where you are executing the code

<?php

class SessionClass {
    
    public function _open($save_path, $session_name) {}
    public function _close() {}
    public function _read($id) { return true; }
    public function _write($id, $session_data) {
        var_dump($session_data);
    }
    public function _destroy($id) {}
    public function _gc($max) {}


}

$ses_class = new SessionClass();

if (!session_set_save_handler(array(&$ses_class,'_open')
                            ,array(&$ses_class,'_close')
                            ,array(&$ses_class,'_read')
                            ,array(&$ses_class,'_write')
                            ,array(&$ses_class,'_destroy')
                            ,array(&$ses_class,'_gc'))) {

    die("Unable to set handlers");
}

session_start();
//echo "Session id is: ".session_id()."\n";

$_SESSION['a'] = 'b';

function temp() {
 $_SESSION['c'] = 'd';
}

temp();

session_write_close(); // this will call custom _write function


Previous Comments:
------------------------------------------------------------------------

[2009-01-13 12:41:54] guido_jansen at gmx dot de

Description:
------------
I'm using a custom save handler to store my session information in a
database.

The save handler is much like the one on 
http://www.zend.com/zend/spotlight/code-gallery-wade8.php

Everything works fine except one thing

If I change the $_SESSION from within a function, then the argument
which should contain the session_data is emtpy

Reproduce code:
---------------
session_start();
session_set_save_handler( [...] array(&$ses_class, '_write' [...]);

// ...

$_SESSION['a'] = 'b';

function temp() {
 $_SESSION['c'] = 'd';
}

// ...
session_write_close(); // this will call custom _write function

-------------------------------------
class Session() {
// ...
function _write($id, $data) {
var_dump($data);    // <---- here is the output
// ...
}
// ...
}

Expected result:
----------------
Inside the custom session write function, the second argument should
dump as

string(20) "a|s:1:"b";c|s:1:"d";"

Actual result:
--------------
Actually the output is

string(0) ""


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47088&edit=1

Reply via email to