Session variables with a single number will not work, however 1a
will work, as will a1
and even a just single "letter" a
will also work.
1st
<?php
session_start();
$_SESSION["a1"] = "LOGGED";
?>
2nd
<?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
EDIT:
- As per
bob-the-destroyer
's comment:
To add regarding array keys, from 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.