php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19176 The unset() function in the $_SESSION variable seems to work, but it doesn't !!
Submitted: 2002-08-29 14:06 UTC Modified: 2002-08-29 14:21 UTC
From: papejack at hotmail dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.2.2 OS: Linux
Private report: No CVE-ID: None
 [2002-08-29 14:06 UTC] papejack at hotmail dot com
Here we go: the unset function doesn't work for $_SESSION on Linux/Apache/PHP4.2.2. The function seems to work in the current file, but when you reload or go in another PHP page, then you clearly see that it didn't work.

On the other hand, it work perfectly when running PHP4.2.2 on Windows XP/IIS 5.1.

Here is an example that you can try :

<?php
	ob_start();
?>
<html>
<body>
<br><br>
<?php
	//starting the session
	session_start();
	
	echo("At the beginning of the page<br><br>");
	print_r($_SESSION);
	
	if(!isset($_SESSION["AAA"]))
	{
		$_SESSION["AAA"] = "ALLO";
		echo("<br><br>Creation of AAA<br><br>");
	}
	else
	{
		unset($_SESSION["AAA"]);
		echo("<br><br>Deleting AAA<br><br>");
	}
	
	echo("At the end of the page<br><br>");
	print_r($_SESSION);
?>
<br>
<form action="#" method="get">
<input type="submit" value="Refresh">
</form>
</body>
</html>
<?php
	ob_end_flush();
?>

This example work well on WinXP/IIS/PHP4.2.2. the first time you create, the second you delete and the third time you recreate...

But on Linux/Apache/PHP4.2.2, the first time you create, the second you delete and the third time you delete another time, just like all the other time that will come after this one.

Jacques B?rard
papejack@hotmail.com

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-29 14:21 UTC] sander@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the original bug instead.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 16:00:01 2026 UTC