Accessing sessions in loop:

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Antoni

    Accessing sessions in loop:

    Hello,

    Could anyone advise, if I had three sessions as below, is there anyway
    I could access the three in a loop.

    $_SESSION['item1'];
    $_SESSION['item2'];
    $_SESSION['item3'];

    Thank you
  • Justin Wyer

    #2
    Re: Accessing sessions in loop:

    Antoni wrote:
    [color=blue]
    > Hello,
    >
    > Could anyone advise, if I had three sessions as below, is there anyway
    > I could access the three in a loop.
    >
    > $_SESSION['item1'];
    > $_SESSION['item2'];
    > $_SESSION['item3'];
    >
    > Thank you[/color]
    You cannot have 3 sessions, you can only have one session. You have 3
    session variables there and yes you can access them in a loop.

    And your question makes no sense?

    Comment

    • Pieter Nobes

      #3
      Re: Accessing sessions in loop:

      Antoni wrote:[color=blue]
      > Hello,
      >
      > Could anyone advise, if I had three sessions as below, is there anyway
      > I could access the three in a loop.
      >
      > $_SESSION['item1'];
      > $_SESSION['item2'];
      > $_SESSION['item3'];
      >
      > Thank you[/color]
      <?php
      for ( $i = 0; $i++; $i <= 3 ) {
      echo $_SESSION['item' . $i];
      }
      ?>

      --
      Pieter Nobels

      Comment

      • Elliott C. Bäck

        #4
        Re: Accessing sessions in loop:

        Antoni wrote:
        [color=blue]
        > Hello,
        >
        > Could anyone advise, if I had three sessions as below, is there anyway
        > I could access the three in a loop.
        >
        > $_SESSION['item1'];
        > $_SESSION['item2'];
        > $_SESSION['item3'];
        >
        > Thank you[/color]

        foreach($_SESSI ON as $key => $value){
        // do things
        }

        or

        for($i = 1; $i <= 3; $i++){
        $var = $_SESSION["item$i"];
        }

        --
        Elliott C. Bäck
        Sitemizi sizleri en iyi iddaa bahis siteleriyle buluşturmak için açmış bulunmaktayız arkadaşlar. Burada Türkiye'nin seçilmiş kaliteli ve güvenilir bahis sitelerini bulabilirsiniz. Kayıt, üyelik, para yatırma, para çekme, canlı bahis, giriş veya mobil giriş gibi birçok konuya değinerek en ince ayrıntısına kadar sitelerin detaylarını sizlere sunmaktayız. Ayrıca bahis hakkında çok çeşitli bilgiler de bulma şansınız var.

        Comment

        • kingofkolt

          #5
          Re: Accessing sessions in loop:

          "Pieter Nobes" <pieterRE@MOVE. opengate.be> wrote in message
          news:7q2Vc.2190 25$fx5.10753094 @phobos.telenet-ops.be...[color=blue]
          > Antoni wrote:[color=green]
          > > Hello,
          > >
          > > Could anyone advise, if I had three sessions as below, is there anyway
          > > I could access the three in a loop.
          > >
          > > $_SESSION['item1'];
          > > $_SESSION['item2'];
          > > $_SESSION['item3'];
          > >
          > > Thank you[/color]
          > <?php
          > for ( $i = 0; $i++; $i <= 3 ) {[/color]
          [...]

          The $i must = 1 not 0.


          Comment

          Working...