php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12826 session_unregister() array_walk() immune? :)
Submitted: 2001-08-18 12:03 UTC Modified: 2001-08-18 12:37 UTC
From: joustin at plusnet dot pl Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.0.6 OS: Win2000 SP2
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: joustin at plusnet dot pl
New email:
PHP Version: OS:

 

 [2001-08-18 12:03 UTC] joustin at plusnet dot pl
Check this out!
I thought array_walk would be a good workaround for the session_unregister limitation of 'one variable unregistering at a time'.

<?	session_start();
	$one = 1;
	$two = 2;
	
	session_register('one','two');
	
	$foo = array('one','two');
	@array_walk($foo,'session_unregister');
	
	if(session_is_registered('one') || session_is_registered('two')){
		echo 'why?';
	}
?>

Well.. there is even a workaround for this workaround, but when you look at it, it makes you smile ironically :)

<?	function damn_unregister($what){
		session_unregister($what);
	}
	@array_walk($foo,'damn_unregister');
	if(!session_is_registered('one') && !session_is_registered('two')){
		echo 'now ok';
	}
?>

What am I missing here ?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-18 12:15 UTC] sniper@php.net
RTFM: http://www.php.net/manual/en/function.array-walk.php

"func must be a user-defined function, and can't be a native 
PHP function. Thus, you can't use array_walk() straight with 
str2lower(), you must build a user-defined function with it 
first, and pass this function as argument."

--Jani

 [2001-08-18 12:37 UTC] mfischer@php.net
If you want to stick to a one-liner, you can use

array_walk($foo,create_function('$e','session_unregister($i);'));

- Markus
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun May 11 06:01:29 2025 UTC