note 58390 deleted from function.session-set-save-handler by danbrown
| From: | danbrown@php.net | Date: | Sun, 23 Jan 2011 16:18:13 +0000 |
| Subject: | note 58390 deleted from function.session-set-save-handler by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176044@lists.php.net to get a copy of this message | ||
Note Submitter: Jaik
----
I have something to add to the note from rudy dot metzger at pareto dot nl.
As objects are being destroyed before sessions are written as of PHP 5.0.5, we can use a
__destruct() method to call session_write_close() in a class-based session handler.
It is possible for your session handling class to use other objects. It's just a matter of
calling session_write_close() at the end of your script, rather in a __destruct() method.
eg.
<?php
echo "You've been to this page " . $oSession->hits . " times before";
$oSession->hits++;
session_write_close();
?>
It's generally best to make declare a function in your common include file(s) that is called at
the end of every script on your site. That way you can do any cleanups you need, and also call
session_write_close().