RE: Bug IDs #8772, #9002, maybe #9724 - session write handler and register_globals
| From: | Jaime Bozza | Date: | Fri, 16 Mar 2001 20:53:23 +0000 |
| Subject: | RE: Bug IDs #8772, #9002, maybe #9724 - session write handler and register_globals | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-44317@lists.php.net to get a copy of this message | ||
Hello,
(Using both 4.0.4pl1 and latest CVS as of today.) I have been having
similar problems with defining my own session handling routings and
register_globals. If register_globals is off, a new session doesn't seem to
call the "write" handler, thus the session never gets stored. With
register_globals=on, the session gets stored correctly.
I've done some testing and found out a fix to the problems which ends up
being better than keeping register_globals on. Here's my code for my "read"
handler (PostgreSQL-based).
------------------
function sess_read($sid) {
global $SESS_DBH;
$qry = "SELECT value FROM sessions WHERE sid = '$sid'";
$qid = pg_exec($SESS_DBH, $qry);
if (pg_numrows($qid) > 0) {
list($value) = pg_fetch_row($qid, 0);
return $value;
}
return "";
}
-------------------
Originally (last line in function above)php-general@lists.php.net, I was
returning a FALSE instead of a blank string. When I switched over to
returning a blank string (when there wasn't any data in the session
database), my "write" handler gets called correctly.
I'm not sure if this will fix anybody else's problems, but if you change
your read handler to return a blank string instead of a FALSE condition, it
may start working for you as well! (If it DOES help you out, please let me
know.)
Jaime Bozza