General sessions question

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

    #1

    General sessions question

    Every example I find on the web, and in the books I've purchased,
    clearly explains how to setup a session handler for MySql, and usually
    provides a very clear example of a main page that checks to see if a
    particular $_SESSION value exists, and if not redirects to a login page
    where the session is started, and the $_SESSION value is set. This is
    great, makes perfect sense. But what about after that? What happens on
    the next page the person goes to? What happens to the $_SESSION
    values? Mine go away.

    Is there somewhere to find what to do so that I can access the $_SESSION
    values, and continue to validate this user is really allowed into the
    next page?

    I have in my php.ini the following:
    session.save_ha ndler="user"
    session.use_onl y_cookies="1"
    session.gc_maxl ifetime="3600"

    Then, I have an include file with this:
    session_set_sav e_handler("sess _open", "sess_close ", "sess_read" ,
    "sess_write ", "sess_destr oy", "sess_gc");

    session_start() ;

    $sessid = session_id();
    if(!$sessid)
    die("Failed to start session");

    The handlers are from one of my books and do make the entry into the
    database when I login. After successful login, I am redirected to a
    subdirectory to the index.php file there. That file includes my
    database connection variables, and the sessions include file described
    above. The $sessid variable has a value in it - it doesn't die. But my
    $_SESSION object has no values in it at all. I'm obviously missing
    something, but none of the instructors explain how to go beyond the
    login page!

    Please help.....


    Tom
  • Sjoerd

    #2
    Re: General sessions question

    tomb wrote:
    What happens to the $_SESSION
    values? Mine go away.
    Did you call session_start() before doing anything with $_SESSION? On
    both the login page and the next page?

    Comment

    • tomb

      #3
      Re: General sessions question

      Sjoerd wrote:
      tomb wrote:
      >What happens to the $_SESSION values? Mine go away.
      >
      Did you call session_start() before doing anything with $_SESSION? On
      both the login page and the next page?
      Yes, absolutely. It's in the include file, so it's called immediately
      after the database stuff and the session_set_sav e_handler function
      call. The $sessid variable is getting a value after session_start() ,
      it's just the $_SESSION object that ends up with nothing in it. I
      thought this was supposed to maintain the values for this user until the
      session expires?

      Tom

      Comment

      • Chuck Anderson

        #4
        Re: General sessions question

        tomb wrote:
        Every example I find on the web, and in the books I've purchased,
        clearly explains how to setup a session handler for MySql, and usually
        provides a very clear example of a main page that checks to see if a
        particular $_SESSION value exists, and if not redirects to a login page
        where the session is started, and the $_SESSION value is set. This is
        great, makes perfect sense. But what about after that? What happens on
        the next page the person goes to? What happens to the $_SESSION
        values? Mine go away.
        >
        Is there somewhere to find what to do so that I can access the $_SESSION
        values, and continue to validate this user is really allowed into the
        next page?
        >
        I have in my php.ini the following:
        session.save_ha ndler="user"
        session.use_onl y_cookies="1"
        session.gc_maxl ifetime="3600"
        >
        Then, I have an include file with this:
        session_set_sav e_handler("sess _open", "sess_close ", "sess_read" ,
        "sess_write ", "sess_destr oy", "sess_gc");
        >
        session_start() ;
        >
        $sessid = session_id();
        if(!$sessid)
        die("Failed to start session");
        >
        The handlers are from one of my books and do make the entry into the
        database when I login. After successful login, I am redirected to a
        subdirectory to the index.php file there. That file includes my
        database connection variables, and the sessions include file described
        above. The $sessid variable has a value in it - it doesn't die. But my
        $_SESSION object has no values in it at all. I'm obviously missing
        something, but none of the instructors explain how to go beyond the
        login page!
        >
        Please help.....
        >
        >
        Tom
        >
        Do you have cookies enabled in your browser?

        --
        *************** **************
        Chuck Anderson • Boulder, CO

        *************** **************

        Comment

        • tomb

          #5
          Re: General sessions question



          Chuck Anderson wrote:
          tomb wrote:
          >Every example I find on the web, and in the books I've purchased,
          >clearly explains how to setup a session handler for MySql, and usually
          >provides a very clear example of a main page that checks to see if a
          >particular $_SESSION value exists, and if not redirects to a login
          >page where the session is started, and the $_SESSION value is set.
          >This is great, makes perfect sense. But what about after that? What
          >happens on the next page the person goes to? What happens to the
          >$_SESSION values? Mine go away.
          >>
          >Is there somewhere to find what to do so that I can access the
          >$_SESSION values, and continue to validate this user is really allowed
          >into the next page?
          >>
          >I have in my php.ini the following:
          >session.save_h andler="user"
          >session.use_on ly_cookies="1"
          >session.gc_max lifetime="3600"
          >>
          >Then, I have an include file with this:
          >session_set_sa ve_handler("ses s_open", "sess_close ", "sess_read" ,
          >"sess_write" , "sess_destr oy", "sess_gc");
          > session_start() ;
          > $sessid = session_id();
          > if(!$sessid)
          > die("Failed to start session");
          >>
          >The handlers are from one of my books and do make the entry into the
          >database when I login. After successful login, I am redirected to a
          >subdirectory to the index.php file there. That file includes my
          >database connection variables, and the sessions include file described
          >above. The $sessid variable has a value in it - it doesn't die. But
          >my $_SESSION object has no values in it at all. I'm obviously missing
          >something, but none of the instructors explain how to go beyond the
          >login page!
          >>
          >Please help.....
          >>
          >>
          >Tom
          >>
          >
          Do you have cookies enabled in your browser?
          >
          Absolutely.

          T

          Comment

          • Jerry Stuckle

            #6
            Re: General sessions question

            tomb wrote:
            Sjoerd wrote:
            >tomb wrote:
            >>What happens to the $_SESSION values? Mine go away.
            >>
            >Did you call session_start() before doing anything with $_SESSION? On
            >both the login page and the next page?
            Yes, absolutely. It's in the include file, so it's called immediately
            after the database stuff and the session_set_sav e_handler function
            call. The $sessid variable is getting a value after session_start() ,
            it's just the $_SESSION object that ends up with nothing in it. I
            thought this was supposed to maintain the values for this user until the
            session expires?
            >
            Tom
            But do you call session_start() before ANY output - even white space?

            First of all, get rid of your session handler to eliminate one possible
            cause. Then put your session_start() at the very top of the pages - i.e.

            <?php session_start() ;?>

            Ensure this is the very first line on your pages with no white space
            before them.

            And ensure you've enabled all error reporting in your php.ini file.

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • tomb

              #7
              Re: General sessions question



              Jerry Stuckle wrote:
              tomb wrote:
              >Sjoerd wrote:
              >>tomb wrote:
              >>>What happens to the $_SESSION values? Mine go away.
              >>>
              >>Did you call session_start() before doing anything with $_SESSION? On
              >>both the login page and the next page?
              >Yes, absolutely. It's in the include file, so it's called immediately
              >after the database stuff and the session_set_sav e_handler function
              >call. The $sessid variable is getting a value after session_start() ,
              >it's just the $_SESSION object that ends up with nothing in it. I
              >thought this was supposed to maintain the values for this user until
              >the session expires?
              >>
              >Tom
              >
              But do you call session_start() before ANY output - even white space?
              >
              First of all, get rid of your session handler to eliminate one possible
              cause. Then put your session_start() at the very top of the pages - i.e.
              >
              <?php session_start() ;?>
              >
              Ensure this is the very first line on your pages with no white space
              before them.
              >
              And ensure you've enabled all error reporting in your php.ini file.
              >
              Yes, I call session_start() . It flows like this:
              session_start() ;
              $sessid = session_id();
              if(!$sessid)
              die("Failed to start session");
              It doesn't die, so $sessid is being set with a value. It's just
              $_SESSION that has nothing in it. ???

              T

              Comment

              • Jerry Stuckle

                #8
                Re: General sessions question

                tomb wrote:
                >
                >
                Jerry Stuckle wrote:
                >tomb wrote:
                >>Sjoerd wrote:
                >>>tomb wrote:
                >>>>What happens to the $_SESSION values? Mine go away.
                >>>>
                >>>Did you call session_start() before doing anything with $_SESSION?
                >>>On both the login page and the next page?
                >>Yes, absolutely. It's in the include file, so it's called
                >>immediately after the database stuff and the session_set_sav e_handler
                >>function call. The $sessid variable is getting a value after
                >>session_start (), it's just the $_SESSION object that ends up with
                >>nothing in it. I thought this was supposed to maintain the values
                >>for this user until the session expires?
                >>>
                >>Tom
                >>
                >But do you call session_start() before ANY output - even white space?
                >>
                >First of all, get rid of your session handler to eliminate one
                >possible cause. Then put your session_start() at the very top of the
                >pages - i.e.
                >>
                ><?php session_start() ;?>
                >>
                >Ensure this is the very first line on your pages with no white space
                >before them.
                >>
                >And ensure you've enabled all error reporting in your php.ini file.
                >>
                >
                Yes, I call session_start() . It flows like this:
                session_start() ;
                $sessid = session_id();
                if(!$sessid)
                die("Failed to start session");
                It doesn't die, so $sessid is being set with a value. It's just
                $_SESSION that has nothing in it. ???
                >
                T
                Did you do the other things I asked?

                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                Working...