php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24029 _SESSION foreach problem
Submitted: 2003-06-04 22:59 UTC Modified: 2003-06-05 00:33 UTC
From: don at onlygeeks dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.3.1 OS: Windows 2000
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: don at onlygeeks dot com
New email:
PHP Version: OS:

 

 [2003-06-04 22:59 UTC] don at onlygeeks dot com
I commonly use a foreach to set my POST array into normal variables.

 foreach($_POST as $key=>$value)
   ${$key} = $value;

but, when I tried this to unset sessions (code follows), PHP.EXE pops up a window and declares it has to close.

 foreach($_SESSION as $key)
   unset($_SESSION[$key])

I know I could go a better way about doing this, and I have. I just thought I would share this bit of information with you. :)

Good day.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-05 00:32 UTC] sniper@php.net
1. Using foreach for your POST array is not very useful,
see http://www.php.net/function.extract and http://www.php.net/import_request_variables for better ways to do it.

2. For more information how to use sessions, http://www.php.net/session

And last but not least: Lot of bugs were fixed in PHP 4.3.2, update first.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 13:01:32 2025 UTC