note 113163 added to reserved.variables.session

From: Date: Sat, 07 Sep 2013 03:09:42 +0000
Subject: note 113163 added to reserved.variables.session
Groups: php.notes 
Request: Send a blank email to php-notes+get-196188@lists.php.net to get a copy of this message
Regarding array keys, from http://php.net/manual/en/language.types.array.php, "Strings containing valid integers will be cast to the integer type". The manual on $_SESSION says "An associative array". So an associative array is expected literally...? It does no one any good if this bit of important info about accessing and storing session data remains buried in manual comments. Session variables with a single number will not work, however "1a" will work, as will "a1" and even a just single letter, for example "a" will also work. (Invalid) 1st page <?php session_start(); $_SESSION["1"] = "LOGGED"; ?> 2nd page <?php session_start(); echo $_SESSION["1"]; ?> --------------------------------------------------------------- (Valid) 1st page <?php session_start(); $_SESSION["a"] = "LOGGED"; ?> 2nd page <?php session_start(); echo $_SESSION["a"]; ?> --------------------------------------------------------------- (Valid) 1st page <?php session_start(); $_SESSION["a1"] = "LOGGED"; ?> 2nd page <?php session_start(); echo $_SESSION["a1"]; ?> --------------------------------------------------------------- Example from PHP.net manual on Session variables <?php $_SESSION[1][1] = 'cake'; // fails $_SESSION['v1'][2] = 'cake'; // works ?> Source: http://php.net/manual/en/language.types.array.php ---- Server IP: 69.147.83.199 Probable Submitter: 184.175.14.86 ---- Manual Page -- http://php.net/manual/en/reserved.variables.session.php Edit -- https://master.php.net/note/edit/113163 Del: integrated -- https://master.php.net/note/delete/113163/integrated Del: useless -- https://master.php.net/note/delete/113163/useless Del: bad code -- https://master.php.net/note/delete/113163/bad+code Del: spam -- https://master.php.net/note/delete/113163/spam Del: non-english -- https://master.php.net/note/delete/113163/non-english Del: in docs -- https://master.php.net/note/delete/113163/in+docs Del: other reasons-- https://master.php.net/note/delete/113163 Reject -- https://master.php.net/note/reject/113163 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196188) next »