Session ID Problem

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

    Session ID Problem

    I use a Session ID to remember a user that's logged in on my site,
    which works pretty well for the most part, because index.html sends
    them to a page (index0.php) that starts the session and then sends
    them on to index.php. However, this means that if someone goes
    straight to one of the pages on my site that requires a Session ID to
    allow them access to something, the page returns error strings at the
    top, although it does proceed to display the rest of the page (so at
    least it kind of works). I've tried just putting the session_start() ;
    code right into the same page, but it then returns an error and won't
    display the page at all. Is there any good way to start a session
    within the same page (HTML or PHP) that I plan to locate the variable?
    And just out out of curiousity, why doesn't it work to simply place
    the session_start() ; code earlier in the code than the code to catch
    the session variable?

    Thanks in advance,

    Jonathan
  • Seun Osewa

    #2
    Re: Session ID Problem

    thewebdevelopme nt@yahoo.com (Jonathan) wrote in message news:<6769f8ab. 0401010707.75a6 c8b4@posting.go ogle.com>...[color=blue]
    > least it kind of works). I've tried just putting the session_start() ;
    > code right into the same page, but it then returns an error and won't
    > display the page at all. Is there any good way to start a session
    > Thanks in advance,
    >
    > Jonathan[/color]

    It returns "an error"! _What_ error does it return?

    Comment

    • Chung Leong

      #3
      Re: Session ID Problem

      Well, the easiest way is to turn on auto-session.

      Calling session_start() doesn't cause any session variables to become
      defined. Presumably that's the warning message that you're getting.

      Uzytkownik "Jonathan" <thewebdevelopm ent@yahoo.com> napisal w wiadomosci
      news:6769f8ab.0 401010707.75a6c 8b4@posting.goo gle.com...[color=blue]
      > I use a Session ID to remember a user that's logged in on my site,
      > which works pretty well for the most part, because index.html sends
      > them to a page (index0.php) that starts the session and then sends
      > them on to index.php. However, this means that if someone goes
      > straight to one of the pages on my site that requires a Session ID to
      > allow them access to something, the page returns error strings at the
      > top, although it does proceed to display the rest of the page (so at
      > least it kind of works). I've tried just putting the session_start() ;
      > code right into the same page, but it then returns an error and won't
      > display the page at all. Is there any good way to start a session
      > within the same page (HTML or PHP) that I plan to locate the variable?
      > And just out out of curiousity, why doesn't it work to simply place
      > the session_start() ; code earlier in the code than the code to catch
      > the session variable?
      >
      > Thanks in advance,
      >
      > Jonathan[/color]


      Comment

      • Alejandro Pedraza

        #4
        Re: Session ID Problem

        thewebdevelopme nt@yahoo.com (Jonathan) wrote in message news:<6769f8ab. 0401010707.75a6 c8b4@posting.go ogle.com>...

        First of all, avoid using an .html file because every time it is
        called, the session for the user calling that page is lost.
        Use only .php files and put session_start() early in the script,
        before any output is produced because the session must be started
        before the headers are sent (when producing any kind of output the
        headers are automatically sent). Another possible cause of error while
        using session_start() could arise if you are using windows and haven't
        defined a directory for the sessions.

        If you need any further help, please be a little more specific on you
        script and the exact errors it produces.

        Regards,

        alpeb

        [color=blue]
        > I use a Session ID to remember a user that's logged in on my site,
        > which works pretty well for the most part, because index.html sends
        > them to a page (index0.php) that starts the session and then sends
        > them on to index.php. However, this means that if someone goes
        > straight to one of the pages on my site that requires a Session ID to
        > allow them access to something, the page returns error strings at the
        > top, although it does proceed to display the rest of the page (so at
        > least it kind of works). I've tried just putting the session_start() ;
        > code right into the same page, but it then returns an error and won't
        > display the page at all. Is there any good way to start a session
        > within the same page (HTML or PHP) that I plan to locate the variable?
        > And just out out of curiousity, why doesn't it work to simply place
        > the session_start() ; code earlier in the code than the code to catch
        > the session variable?
        >
        > Thanks in advance,
        >
        > Jonathan[/color]

        Comment

        • Jay

          #5
          Re: Session ID Problem

          I had the same prob until i included this on each page.

          <?
          $memberid = $_SESSION['pp_userid'];

          if (empty($memberi d)) {
          echo "<p><b>Unauthor ised User</b></p>";
          echo "Please click <a href=\"member.p hp\">here</a> to login";
          die;
          }
          ?>


          "Jonathan" <thewebdevelopm ent@yahoo.com> wrote in message
          news:6769f8ab.0 401010707.75a6c 8b4@posting.goo gle.com...[color=blue]
          > I use a Session ID to remember a user that's logged in on my site,
          > which works pretty well for the most part, because index.html sends
          > them to a page (index0.php) that starts the session and then sends
          > them on to index.php. However, this means that if someone goes
          > straight to one of the pages on my site that requires a Session ID to
          > allow them access to something, the page returns error strings at the
          > top, although it does proceed to display the rest of the page (so at
          > least it kind of works). I've tried just putting the session_start() ;
          > code right into the same page, but it then returns an error and won't
          > display the page at all. Is there any good way to start a session
          > within the same page (HTML or PHP) that I plan to locate the variable?
          > And just out out of curiousity, why doesn't it work to simply place
          > the session_start() ; code earlier in the code than the code to catch
          > the session variable?
          >
          > Thanks in advance,
          >
          > Jonathan[/color]


          Comment

          Working...