php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14767 Bug unsetting vars using $_SESSION
Submitted: 2001-12-30 06:58 UTC Modified: 2002-01-02 11:33 UTC
From: anders at gatefive dot fi Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.1.1 OS: Linux 2.4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: anders at gatefive dot fi
New email:
PHP Version: OS:

 

 [2001-12-30 06:58 UTC] anders at gatefive dot fi
In a project I work on I ran into something I would say
is a bug..
When I call the page with ?debug=3 the session var 'test'
gets the value "howdy" and gets stored (no need to call
session_register('test'); (odd?)). After this there seem
to be no way of unsetting/removing this session var..
At least non of the methods below works. Bug?
unset in #2 (see below) removes the var, so it doesn't
show up in the var_dump (#6), but upon calling the page again with ?debug=2 (only show sess-vars), it shows up
again.

At the same: $_GETand $_SERVER is displayed in phpinfo, but not $_SESSION. Another bug?

In php.ini:
register_globals = On

Script:
// #1
if ($debug==3)
  $_SESSION['test'] = "howdy";

// #2
if ($debug==4) 
  unset($_SESSION['test']);

// #3
if ($debug==5) 
  unset($test);

// #4
if ($debug==6) 
  session_unregister($test);

// #5
if ($debug==7) 
  session_unregister($_SESSION['test']);

// #6
if ($debug>1)
  var_dump($_SESSION);

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-02 11:33 UTC] sander@php.net
session_unregister('test') should work. Alternatively, you can use unset($_SESSION['test']);
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC