note 94818 added to function.session-write-close
| From: | prophp at gmail dot com | Date: | Thu, 26 Nov 2009 14:21:04 +0000 |
| Subject: | note 94818 added to function.session-write-close | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163302@lists.php.net to get a copy of this message | ||
Beware, if you overwrite the default PHP Session handling and use debugging code inside the write()
function, the debugging code is not executed until you run session_write_close().
I tried everything, file logging directly from the write() function, global debugging variable
increments, static class properties. The only things written were the session open() and read()
calls. My debugging code looks like this:
<?php
$Session = new Session();
...
class Session() {
public function write($id)
$sql = "UPDATE ... WHERE id=". mysql_real_escape_string($id);
self::$debug_Info .= "session_write sql=$sql";
...
}
# then at the very end of the script:
# session debugging
session_write_close();
error_log($Session->getDebugInfo(), 3, 'logs/sessions.log');
?>
where getDebugInfo simply returns self::$debug_Info. Without session_write_close() the sessions.log
would only contain the open() and read() calls.
Maybe intuitive to many, it took days to realize. hope it helps!
----
Server IP: 85.214.154.209
Probable Submitter: 62.240.129.2
----
Manual Page -- http://www.php.net/manual/en/function.session-write-close.php
Edit -- https://master.php.net/note/edit/94818
Del: integrated -- https://master.php.net/note/delete/94818/integrated
Del: useless -- https://master.php.net/note/delete/94818/useless
Del: bad code -- https://master.php.net/note/delete/94818/bad+code
Del: spam -- https://master.php.net/note/delete/94818/spam
Del: non-english -- https://master.php.net/note/delete/94818/non-english
Del: in docs -- https://master.php.net/note/delete/94818/in+docs
Del: other reasons-- https://master.php.net/note/delete/94818
Reject -- https://master.php.net/note/reject/94818
Search -- https://master.php.net/manage/user-notes.php