Re: Erf, still doesn't work.
| From: | August Zajonc | Date: | Sat, 01 Jul 2000 23:46:11 +0000 |
| Subject: | Re: Erf, still doesn't work. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4327@lists.php.net to get a copy of this message | ||
Yes, this is a known bug with session handling under PHP... I'm attaching a
workaround... You'll find it fixes things. Took me a couple of long and late
nights (and my own session handling in an include file) to finally figure
this one out at 5 AM.
The story is, if you have a session variable set, and it's not in the db
yet, write WILL NOT be called. The trick then is to check on the read if
anything came back from the DB for the session key, and if nothing did call
mysql_session_handler_write ($sessionid, $val) from within the read
statement. This cleans things up nicely. You may still have problems on the
first write but they can be worked around. Give this a try in read(). Of
course, this all doesn't do me much good anymore because I can't get
perisitent connections working anymore with the latest stuff.
function mysql_session_read ($SessionID) {
report_error(__FILE__, __LINE__,"Session Read - $SessionID");
global $SessionTableName;
$SessionID = addslashes($SessionID);
$sql = "SELECT Content FROM $SessionTableName WHERE SessionID =
'$SessionID' LIMIT 1";
if (!$result = sql_query(__FILE__, __LINE__, $sql))
return false;
if (mysql_num_rows($result) == 1)
return mysql_result($result, 0);
}
else
mysql_session_write ($SessionID);
$sql = "SELECT Content FROM $SessionTableName WHERE SessionID =
'$SessionID' LIMIT 1";
if (!$result = sql_query(__FILE__, __LINE__, $sql))
return false;
if (mysql_num_rows($result) == 1)
return mysql_result($result, 0);
}
else
return false;
}
}
}
August
----- Original Message -----
From: "Szii" <szii@earthlink.net>
To: <php-general@lists.php.net>
Sent: Saturday, July 01, 2000 7:40 PM
Subject: [PHP] Erf, still doesn't work.
I placed a configured php.ini file in /usr/local/lib (the default place)
and restarted apache...still didn't pick up my "write()" calls for
the session handlers.
So I rebuilt PHP with the ini still in the default place...no dice.
So I tried ini_set("session.save_handler", "user"); too
Nadas.
I can get open() and read() to work, but not write().
Anyone have any thoughts?
-Szii
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net