php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27818 session_destroy doesn't work
Submitted: 2004-03-31 20:15 UTC Modified: 2006-01-02 09:05 UTC
Votes:14
Avg. Score:3.9 ± 1.2
Reproduced:9 of 9 (100.0%)
Same Version:3 (33.3%)
Same OS:1 (11.1%)
From: ezdevelop at hotmail dot com Assigned:
Status: Wont fix Package: Session related
PHP Version: 5.0.0RC1 OS: win2000 adv server
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
46 - 6 = ?
Subscribe to this entry?

 
 [2004-03-31 20:15 UTC] ezdevelop at hotmail dot com
Description:
------------
When I'm trying to use session_destroy() functioni n the __destruct() function, PHP says:
"Warning: Trying to destroy uninitialized session"

I'v tested the code under Apache and IIS, but all the same mistake.

Reproduce code:
---------------
<?php
class test
{
	function __construct() {
		echo 'Initialize the session.';
		session_start();
	}

	function __destruct() {
		session_destroy();
		echo 'Finally, destroy the session.';
	}
}

$test = new test();
?> 

Expected result:
----------------
Initialize the session.
Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in D:\wwwroot\sess.php on line 10
Finally, destroy the session.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-01 02:14 UTC] derick@php.net
This is actually expected behavior, as the session is already automatically closed before destructors are run. There is some trickery in the engine now that perhaps makes it possible to "fix" this, but we'll suspend this for now.
 [2004-04-12 14:27 UTC] alan dot warden at btinternet dot com
The behaviour is the same if the session is started when php start by settin session.auto_start = 1
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 07:01:32 2024 UTC