php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11527 session_unregister() seems not work properly
Submitted: 2001-06-17 20:06 UTC Modified: 2001-11-18 01:37 UTC
From: ccjeagle at ms6 dot hinet dot net Assigned:
Status: Closed Package: Session related
PHP Version: 4.0.5 OS: FreeBSD 4.3 STABLE
Private report: No CVE-ID: None
 [2001-06-17 20:06 UTC] ccjeagle at ms6 dot hinet dot net
It seems that session_unregister() should "remove" a var
from the session, isn't it ?

-------test.php
<?php
// First script, register the var
session_start() ;
session_register("somevar") ;
$HTTP_SESSION_VARS["somevar"] = "abc" ;
?>
<a href="test2.php">Click Here</a>

-------test2.php
<?php
// Second script, unregister the var
session_start() ;
echo "somevar is " . $HTTP_SESSION_VARS["somevar"] ;
session_unregister("somevar") ;
?>
<br><a href="test3.php">Click here again</a>

--------test3.php
<?php
// The third script, see the result
session_start() ;
print_r($HTTP_SESSION_VARS) ;
session_unset() ;
print_r($HTTP_SESSION_VARS) ;
session_destroy() ;
?>

With the enable-trans-sid turned on, the result of the third
script is :
Array ( [somevar] => abc ) Array ( )

Is it a bug ?
How shoud I do if I want to "remove" some variables from
session but KEEP THE OTHERS unchanged ?

Best Regards

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-17 21:41 UTC] ccjeagle at ms6 dot hinet dot net
Well I found a solution. Just replace session_unregister()
by unset() statement.
 [2001-06-18 08:56 UTC] sniper@php.net
Yes, when you unregister something, you also need to unset
it if you want it to be unset immediately.

 [2001-06-18 21:24 UTC] ccjeagle at ms6 dot hinet dot net
> Yes, when you unregister something,
> you also need to unset it if you want it
> to be unset immediately.

Maybe I was wrong, but "Unregister" takes place in the
SECOND script, and the THIRD one still record the
"unregistered" variable ????


 [2001-06-19 12:26 UTC] sniper@php.net
You should be using this:

$somevar = "abc";

Not the globals array.

Works for me with PHP 4.0.6RC3 just fine then.

http://www.php.net/~andi/php-4.0.6RC3.tar.gz


 [2001-06-20 06:27 UTC] cynic@php.net
Hi Jani,

does your comment mean register_globals off is deprecated? I don't think so. :)
 [2001-11-18 01:37 UTC] sebastian@php.net
This is not a bug. Reading the comments on http://www.php.net/manual/en/function.session-unregister.php should make this clear.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 11:01:31 2024 UTC