Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #38241 : session_set_save_handler() can't work well
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 15th June 04:16
php-bugs
External User
 
Posts: 1
Default #38241 : session_set_save_handler() can't work well



ID: 38241
User updated by: qw_kerry at yahoo dot com dot cn
Reported By: qw_kerry at yahoo dot com dot cn
-Status: Feedback
+Status: Open
Bug Type: Session related
-Operating System: Windows 2003
+Operating System: Windows 2003 SP1
PHP Version: 5CVS-2006-07-28 (snap)
New Comment:

Description:
------------
I use session_set_save_handler() to define my own session handler. It
can read session values, but can't write them. But the function work
well when I run my script on php 5.1.4.

Environment
OS: Windows 2003 SP1
Apache: 2.2.2
Mysql: 5.0.22

Reproduce code:
---------------
You can find my script in the following url.
http://www.30t.net/bug/session.txt

The session table structure is defined as

CREATE TABLE `session` (
sessionid char(28) character set latin1 collate latin1_general_ci NOT
NULL,
lastupdated int(11) NOT NULL,
datavalue varchar(1000) character set latin1 collate
latin1_general_ci NOT NULL,
PRIMARY KEY (sessionid)
) ENGINE=MEMORY DEFAULT CHARSET=utf8;

Expected result:
----------------
One new row should appear in the session table.

Actual result:
--------------
Fatal error: Call to a member function prepare() on a non-object in
E:\sumly2007\test.php on line 6


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

[2006-07-28 09:31:46] tony2001@php.net

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.

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

[2006-07-28 09:26:01] qw_kerry at yahoo dot com dot cn

Description:
------------
I use session_set_save_handler() to define my own session handler. It
can read session values, but can't write them. But the function work
well when I run my script on php 5.1.4.

Session is stored in database in my script. When I store session in


Reproduce code:
---------------
The functions except for DBSessionWrite are omitted. PDO_MYSQL is
used.

function DBSessionWrite($aKey,$aVal)
{
global $_sessiondb,$_sessiontable;
$sql = "SELECT lastupdated FROM ".$_sessiontable." WHERE sessionid=?";
$stmt = $_sessiondb->prepare($sql);
$stmt->execute($aKey);
if($stmt->fetchColumn()) {
$sql = "UPDATE ".$_sessiontable." SET datavalue=?, lastupdated=? WHERE sessionid=?";
$stmt = $_sessiondb->prepare($sql);
$stmt->execute(array($aVal,time(),$aKey));
}
else {
$sql = "INSERT INTO ".$_sessiontable." VALUES (?,?,?)";
$stmt = $_sessiondb->prepare($sql);
$stmt->execute(array($aKey,time(),$aVal)); }
return $stmt->rowCount();
}


session_set_save_handler("DBSessionOpen", "DBSessionClose",
"DBSessionRead", "DBSessionWrite", "DBSessionDestroy", "DBSessionGC");
session_start();

$session_idencode = md5($_SERVER["REMOTE_ADDR"]);
if($session_idencode != $_SESSION['idencode']) {
session_regenerate_id(true);
$_SESSION['idencode'] = $session_idencode;
}

Expected result:
----------------
One new row should appear in the session table.

Actual result:
--------------
No new row appear.


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


--
Edit this bug report at http://bugs.php.net/?id=38241&edit=1
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666