From: nospam0 at malkusch dot de Operating system: Linux PHP version: 5.0.0b1 (beta1) PHP Bug Type: Session related Bug description: session is not available in __destruct()
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 bug report at http://bugs.php.net/?id=26099&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26099&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26099&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26099&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26099&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26099&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=26099&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26099&r=support Expected behavior: http://bugs.php.net/fix.php?id=26099&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26099&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26099&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26099&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26099&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26099&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26099&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26099&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26099&r=float