|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-07-28 09:31 UTC] tony2001@php.net
[2006-07-29 09:04 UTC] qw_kerry at yahoo dot com dot cn
[2006-07-30 10:19 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 21:00:02 2025 UTC |
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.