From: qw_kerry at yahoo dot com dot cn
Operating system: Windows 2003
PHP version: 5CVS-2006-07-28 (snap)
PHP Bug Type: Session related
Bug description: session_set_save_handler() can't work well
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 files,
session is written well.
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 bug report at http://bugs.php.net/?id=38241&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=38241&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=38241&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=38241&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38241&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=38241&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38241&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38241&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38241&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38241&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38241&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=38241&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=38241&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38241&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38241&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38241&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38241&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38241&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38241&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38241&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38241&r=mysqlcfg