retrieving data from session id??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • crescent_au@yahoo.com

    retrieving data from session id??

    Hi all,

    Please help me out here.

    This is what I have done:

    on Page A:
    <a href="<?php echo 'pageB.php?item =docs&sSID='.se ssion_id();
    ?>">Docs</a>

    on PageB:
    <?php
    if ($sSID) {
    echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
    switch($_REQUES T['item']) {
    case "docs": echo "doc files"; break;
    case "reqdocs": echo "other files"; break;
    case "misc": echo "miscellane ous files"; break;
    default: echo "Invalid query"; break;
    }
    }
    ?>

    As you can see on PageB, I tried to read the value of
    $_SESSION['username'] but it gives nothing. The session file is
    correctly created in my /tmp folder with the username field containing
    valid data.

    Am I missing something?

    Thanks
    Ben

  • m2m tech

    #2
    Re: retrieving data from session id??

    You have to tell PageB to do something with the session created by
    PageA. For example:

    session_id ($_GET['sSID'])

    but be shure to clean sSID before you use it like this ...



    crescent_au@yah oo.com wrote:
    Hi all,
    >
    Please help me out here.
    >
    This is what I have done:
    >
    on Page A:
    <a href="<?php echo 'pageB.php?item =docs&sSID='.se ssion_id();
    ?>">Docs</a>
    >
    on PageB:
    <?php
    if ($sSID) {
    echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
    switch($_REQUES T['item']) {
    case "docs": echo "doc files"; break;
    case "reqdocs": echo "other files"; break;
    case "misc": echo "miscellane ous files"; break;
    default: echo "Invalid query"; break;
    }
    }
    ?>
    >
    As you can see on PageB, I tried to read the value of
    $_SESSION['username'] but it gives nothing. The session file is
    correctly created in my /tmp folder with the username field containing
    valid data.
    >
    Am I missing something?
    >
    Thanks
    Ben
    >

    --
    --------------------------------------------
    m2m server software gmbh - http://www.m2m.at

    Comment

    • Mumia W.

      #3
      Re: retrieving data from session id??

      On 08/15/2006 01:10 AM, crescent_au@yah oo.com wrote:
      Hi all,
      >
      Please help me out here.
      >
      This is what I have done:
      >
      on Page A:
      <a href="<?php echo 'pageB.php?item =docs&sSID='.se ssion_id();
      ?>">Docs</a>
      [...]
      The parameter "sSID" is not the default PHP session id
      parameter name, which is PHPSESSID. You might have
      'session.name' in your configuration to 'sSID'; I don't know.

      Under certain circumstances, PHP automatically sets the
      PHPSESSID parameter for you. Read the docs to see if you can
      get that to work.

      (Follow ups set to alt.comp.lang.p hp)

      Comment

      • Shelly

        #4
        Re: retrieving data from session id??


        <crescent_au@ya hoo.comwrote in message
        news:1155622217 .002064.121000@ 75g2000cwc.goog legroups.com...
        Hi all,
        >
        Please help me out here.
        >
        This is what I have done:
        >
        on Page A:
        <a href="<?php echo 'pageB.php?item =docs&sSID='.se ssion_id();
        ?>">Docs</a>
        >
        on PageB:
        <?php
        if ($sSID) {
        echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
        switch($_REQUES T['item']) {
        case "docs": echo "doc files"; break;
        case "reqdocs": echo "other files"; break;
        case "misc": echo "miscellane ous files"; break;
        default: echo "Invalid query"; break;
        }
        }
        ?>
        >
        As you can see on PageB, I tried to read the value of
        $_SESSION['username'] but it gives nothing. The session file is
        correctly created in my /tmp folder with the username field containing
        valid data.
        >
        Am I missing something?
        >
        Thanks
        Ben
        Try adding to all pages at the top in the php area:

        session_start() ;

        Shelly


        Comment

        • Jahjah92

          #5
          Re: retrieving data from session id??

          hi,
          before trying to retrieve values in $_SESSION , you have to call
          session_start() , and php will fill the array of session.
          A+

          "m2m tech" <tech@m2m.ata écrit dans le message de news:
          44e18226$0$1048 0$91cee783@news reader01.highwa y.telekom.at...
          You have to tell PageB to do something with the session created by PageA.
          For example:
          >
          session_id ($_GET['sSID'])
          >
          but be shure to clean sSID before you use it like this ...
          >
          >
          >
          crescent_au@yah oo.com wrote:
          >
          >Hi all,
          >>
          >Please help me out here.
          >>
          >This is what I have done:
          >>
          >on Page A:
          ><a href="<?php echo 'pageB.php?item =docs&sSID='.se ssion_id();
          >?>">Docs</a>
          >>
          >on PageB:
          ><?php
          >if ($sSID) {
          >echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
          >switch($_REQUE ST['item']) {
          >case "docs": echo "doc files"; break;
          >case "reqdocs": echo "other files"; break;
          >case "misc": echo "miscellane ous files"; break;
          >default: echo "Invalid query"; break;
          >}
          >}
          >?>
          >>
          >As you can see on PageB, I tried to read the value of
          >$_SESSION['username'] but it gives nothing. The session file is
          >correctly created in my /tmp folder with the username field containing
          >valid data.
          >>
          >Am I missing something? Thanks
          >Ben
          >>
          >
          >
          --
          --------------------------------------------
          m2m server software gmbh - http://www.m2m.at

          Comment

          • Rik

            #6
            Re: retrieving data from session id??

            crescent_au@yah oo.com wrote:
            Hi all,
            >
            Please help me out here.
            >
            This is what I have done:
            >
            on Page A:
            <a href="<?php echo 'pageB.php?item =docs&sSID='.se ssion_id();
            >">Docs</a>
            >
            on PageB:
            <?php
            if ($sSID) {
            echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
            switch($_REQUES T['item']) {
            case "docs": echo "doc files"; break;
            case "reqdocs": echo "other files"; break;
            case "misc": echo "miscellane ous files"; break;
            default: echo "Invalid query"; break;
            }
            }
            >>
            >
            As you can see on PageB, I tried to read the value of
            $_SESSION['username'] but it gives nothing. The session file is
            correctly created in my /tmp folder with the username field containing
            valid data.
            >
            Am I missing something?
            1. session_name() on EVERY page.
            2. session_start() on EVERY page.
            3. Don't use $sSID, use $_GET['sSid'];

            Grtz,
            --
            Rik Wasmus


            Comment

            • Petr Vileta

              #7
              Re: retrieving data from session id??

              <crescent_au@ya hoo.compíse v diskusním príspevku
              news:1155622217 .002064.121000@ 75g2000cwc.goog legroups.com...
              Hi all,
              >
              Please help me out here.
              >
              Am I missing something?
              >
              Yes ;-) You must start session on each page where you want set or get
              session infos and close it.

              on Page A:
              <?php
              session_start() ; // THIS IS IMPORTANT
              <a href="<?php echo 'pageB.php?item =docs&sSID='.se ssion_id();
              session_write_c lose(); // THIS IS IMPORTANT TOO
              ?>">Docs</a>

              on PageB:
              <?php
              session_start() ; // THIS IS IMPORTANT
              if ($sSID) {
              echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
              ....
              session_write_c lose(); // THIS IS IMPORTANT TOO
              ?>
              --

              Petr Vileta, Czech republic
              (My server rejects all messages from Yahoo and Hotmail. Send me your mail
              from another non-spammer site please.)


              Comment

              Working...