Numeric indexes in $_SESSION ??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Svend Andreas Horgen

    Numeric indexes in $_SESSION ??

    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($_SESSI ON); //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($_SESSI ON); //not as expected, only last element, and this will
    always be 1.

    Regards,
    Svend Andreas Horgen.


  • Jedi121

    #2
    Re: Numeric indexes in $_SESSION ??

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

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


    Comment

    • Svend Andreas Horgen

      #3
      Re: Numeric indexes in $_SESSION ??

      "Jedi121" <jedi121news@fr ee.fr.Removethi s> skrev i melding
      news:mesnews.f3 d77d44.47ee41ab .644.2689@free. fr.Removethis.. .[color=blue]
      > Svend Andreas Horgen a écrit le 30/04/2004 :[color=green]
      > > $id = "number" . 3;
      > > $_SESSSION[$id]++;
      > > $id = "number" . 5;
      > > $_SESSSION[$id]++;[/color]
      >
      > I imagine $_SESSSION is a typing error because there's only 2 's' in
      > $_SESSION[/color]


      Sorry, but in my script it is to 's'. Still won't work.


      Comment

      Working...