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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ezdevelop at hotmail dot com
New email:
PHP Version: OS:

 

 [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: Thu Apr 25 21:01:36 2024 UTC