ID: 26099 Comment by: lokrain at gmail dot com Reported By: nospam0 at malkusch dot de Status: Open Bug Type: Feature/Change Request Operating System: Linux PHP Version: 5.0.0b2 (beta2) New Comment:
I think you can still call session_destroy() or any other session functions using register_shutdown_function(). You even can work around that with hidden iframes, if you want to destroy a class before the main php end, but I think this is not the case you are looking for. Previous Comments: ------------------------------------------------------------------------ [2003-11-03 15:53:16] nospam0 at malkusch dot de Description: ------------ Actually I'm talking about beta2 of PHP5, but it wasn't listed. I think the __destruct() method should do things like cleaning up any resources. So it would be nice if I could destroy Sessions which are empty. But the Session Handler for closing the Session is called before the __destruct() methods. Reproduce code: --------------- class Bug { private $i = 0; public function __construct() { session_start(); if ( isset( $_SESSION['i'] ) ) { $this->i = $_SESSION['i']; } $this->i ++; $_SESSION['i'] = $this->i; } public function printLink() { echo '<a href="/?' . SID . '">Bug</a>: ' . $this->i; } public function __destruct() { if ( $this->i > 4 ) { session_destroy(); } } } $bug = new Bug(); $bug->printLink(); Expected result: ---------------- I would expect that the Session is still active and can be manipulated in any __destruct() method. Actual result: -------------- PHP's Session Handler for closing the Session is called before any __destruct method. So I can't do anything with the Session in the __destruct method. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26099&edit=1