Re: Postgresql session handling
| From: | Bolt Thrower | Date: | Wed, 21 Feb 2001 00:33:58 +0000 |
| Subject: | Re: Postgresql session handling | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-40865@lists.php.net to get a copy of this message | ||
"Richard Lynch" <richard@zend.com> wrote:
> The writing of the session data occurs *after* the server-browser HTTP
> connection is cut.
> If you have any error-reporting happening in your session_write function,
> you won't see it.
> Alter that function to log errors to a file or something.
It seems the pgsql_session_write() function is not even being invoked.
Here it is:
+-----------------------------------------------------------------
| function pgsql_session_write($key, $val)
| {
| /* debugging */
| $fp = fopen("/tmp/phpdebugwrite","w") or die ("can't open
file");
| fwrite($fp, "HERE");
| fclose($fp);
| /* end debug */
|
| global $pgsql_session_handle, $pgsql_session_table;
|
| $key = addslashes($key);
| $val = addslashes($val);
| $now = time();
|
|
|
| /*
| * Delete any existing data for this session and then insert a new row
| * containing the current session data, all in a single transaction.
| * This should prevent collisions between multiple session instances.
| *
| * Thanks to "Will Fitzgerald" <fitzgerald@inetmi.com>.
| */
| $query = 'begin; ';
| $query .= "delete from $pgsql_session_table where session_id = '$key'; ";
| $query .= "insert into $pgsql_session_table values('$key', $now,
'$val'); ";
| $query .= 'commit;';
| $result = @pg_exec($pgsql_session_handle, $query);
|
| $ret = (pg_cmdtuples($result) == 0);
| pg_freeresult($result);
|
| return ($ret);
| }
+-----------------------------------------------------------------
I've added the debugging statements at the top. Can you see anything
wrong with this function? At the end of the include file in which
this appears, is the session_set_save_handler() call:
session_set_save_handler(
'pgsql_session_open',
'pgsql_session_close',
'pgsql_session_read',
'pgsql_session_write',
'pgsql_session_destroy',
'pgsql_session_gc'
);
Thanks,
--
Steve <news@teiresias.net>
"And when you walk in golden halls, you get to keep the gold that falls"
-- Black Sabbath, "Heaven and Hell"