By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,466 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,466 IT Pros & Developers. It's quick & easy.

Numeric indexes in $_SESSION ??

P: n/a
I used to believe I fully understood sessions... Apparently PHP does not
handles numeric indexes in $_SESSION, as far as I can see. The same yields
for both PHP 4 and 5. Suggestions or explanations to the following? I
thought $_SESSION was a super global array, but arrays would for sure allow
for numeric indices, right?

As an example, this works:

$id = "number" . 3;
$_SESSSION[$id]++;
$id = "number" . 5;
$_SESSSION[$id]++;
print_r($_SESSION); //as expected, two elements occur on screen

If the variable does not exist, it is set to 1, else it is increased (some
code is cut away)
This does, strangely, not work:

$id = 3;
$_SESSSION[$id]++;
$id = 5;
$_SESSSION[$id]++;
print_r($_SESSION); //not as expected, only last element, and this will
always be 1.

Regards,
Svend Andreas Horgen.
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Svend Andreas Horgen a écrit le 30/04/2004 :
$id = "number" . 3;
$_SESSSION[$id]++;
$id = "number" . 5;
$_SESSSION[$id]++;


I imagine $_SESSSION is a typing error because there's only 2 's' in
$_SESSION
Jul 17 '05 #2

P: n/a
"Jedi121" <je*********@free.fr.Removethis> skrev i melding
news:me********************************@free.fr.Re movethis...
Svend Andreas Horgen a écrit le 30/04/2004 :
$id = "number" . 3;
$_SESSSION[$id]++;
$id = "number" . 5;
$_SESSSION[$id]++;


I imagine $_SESSSION is a typing error because there's only 2 's' in
$_SESSION

Sorry, but in my script it is to 's'. Still won't work.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.