#32279 [Opn]: _SESSION treated as super global without session_start()

From: Date: Sat, 12 Mar 2005 23:44:29 +0000
Subject: #32279 [Opn]: _SESSION treated as super global without session_start()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-75262@lists.php.net to get a copy of this message
ID: 32279 Updated by: pollita@php.net Reported By: pguilbault at iweb dot ca Status: Open Bug Type: Session related PHP Version: 5.0.3 New Comment: The way ZE is designed, this behavior is pretty darned unlikely to change anytime before PHP7. HOWEVER: I would qualify it as an "undocumented feature", as such it is subject to removal without notice. So use at your own risk. Plus, as sniper said, if your PHP was compiled with --disable-session then $_SESSION will be unavailable anyway. To ensure maximum compatability you're best off use $GLOBALS['somevar']['index'] = 'foo'; or global $somevar; $somevar['index'] = 'foo'; Previous Comments: ------------------------------------------------------------------------ [2005-03-12 19:23:30] tony2001@php.net Well, personally I don't think it's a bug. Other autoglobals are registered in the same time too (i.e. at module init time). ------------------------------------------------------------------------ [2005-03-12 14:43:42] sniper@php.net Yes, it's definately a bug. And I wouldn't suggest using $_SESSION like that as we might a) fix this bug b) this won't work if session extension is not enabled.. ------------------------------------------------------------------------ [2005-03-11 15:54:38] pguilbault at iweb dot ca Description: ------------ Without using session_start() and setting $_SESSION['test']='hi there'; in a class and echoing thise $_SESSION['test'] outside the class with echo the 'hi there'... I was told it was a bug... Althougth I am hoping it is NOT a bug and that I will be able to use that super global for my Session Management class. So I can use $_SESSION['test'] in my classes instead of $GLOBAS['session_vars']['test']. which is way too long for my test. Reproduce code: --------------- class tester() { function __construct() { $_SESSION['test'] = 'hi there'; } } $test = new tester(); echo $_SESSION['test']; Expected result: ---------------- hi there ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32279&edit=1

« previous php.bugs (#75262) next »