PHP session variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ronnil
    Recognized Expert New Member
    • Jun 2007
    • 134

    #16
    try to echo out session_id() just below your session_start() statement. If those two are not the same, you got a problem with your browser starting a new session for each request.

    Just for eleminating that possibility

    Comment

    • twinklyblue
      New Member
      • Jun 2007
      • 37

      #17
      Originally posted by ajaxrand
      Why don't you post the complete scripts for both the pages here in the forum.
      Hi ajaxrand, I did post the complete code above but will post it again for easier reference.

      first page:
      <?php
      session_start() ;
      $_SESSION['session_var'] = "testing";
      ?>
      <html>
      <body>
      <p>This is a test of the sessions feature
      <form action="session Test2.php" method = "POST">
      <input type="text" name="form_var" value ="testing">
      <input type="submit" value="Go to the next page">
      </body>
      </html>

      second page:
      <?php
      session_start() ;
      echo "test ".$session_ var;
      ?>
      <html>
      <body>
      <?php
      $session_var = $_SESSION['session_var'];
      $form_var = $_POST['form_var'];
      echo "session_va r =".$session_var ."<br>\n";
      echo "form_var =".$form_var."< br>\n";
      ?>
      </body>
      </html>

      This is the output:

      test session_var =
      form_var =testing

      Comment

      • twinklyblue
        New Member
        • Jun 2007
        • 37

        #18
        Originally posted by ronnil
        try to echo out session_id() just below your session_start() statement. If those two are not the same, you got a problem with your browser starting a new session for each request.

        Just for eleminating that possibility
        I also did try that and came with a null result. Any settings that I can check with the browser?

        Comment

        • ronnil
          Recognized Expert New Member
          • Jun 2007
          • 134

          #19
          do you mean that session_id() is null? in that case your session is not registered at all.

          I actually don't know how to set that configuration, since I've never had that problem myself :D

          Comment

          • ak1dnar
            Recognized Expert Top Contributor
            • Jan 2007
            • 1584

            #20
            Double check this parameters with your configuration settings under your php.ini.just go for a phpinfo() again.

            in each and every line this is the format.
            Directive - Local Value - Master Value
            session.auto_st art - Off - Off


            Code:
            session.auto_start    Off    Off
            session.bug_compat_42    On    On
            session.bug_compat_warn    On    On
            session.cache_expire    180    180
            session.cache_limiter    nocache    nocache
            session.cookie_domain    no value    no value
            session.cookie_lifetime    0    0
            session.cookie_path    /    /
            session.cookie_secure    Off    Off
            session.entropy_file    no value    no value
            session.entropy_length    0    0
            session.gc_divisor    100    100
            session.gc_maxlifetime    1440    1440
            session.gc_probability    1    1
            session.hash_bits_per_character    4    4
            session.hash_function    0    0
            session.name    PHPSESSID    PHPSESSID
            session.referer_check    no value    no value
            session.save_handler    files    files
            session.save_path    C:\DOCUME~1\PRARTH~1.PC\LOCALS~1\Temp    C:\DOCUME~1\PRARTH~1.PC\LOCALS~1\Temp
            session.serialize_handler    php    php
            session.use_cookies    On    On
            session.use_only_cookies    Off    Off
            session.use_trans_sid    0    0

            Comment

            • twinklyblue
              New Member
              • Jun 2007
              • 37

              #21
              Originally posted by ajaxrand
              Double check this parameters with your configuration settings under your php.ini.just go for a phpinfo() again.

              in each and every line this is the format.
              Directive - Local Value - Master Value
              session.auto_st art - Off - Off


              Code:
              session.auto_start    Off    Off
              session.bug_compat_42    On    On
              session.bug_compat_warn    On    On
              session.cache_expire    180    180
              session.cache_limiter    nocache    nocache
              session.cookie_domain    no value    no value
              session.cookie_lifetime    0    0
              session.cookie_path    /    /
              session.cookie_secure    Off    Off
              session.entropy_file    no value    no value
              session.entropy_length    0    0
              session.gc_divisor    100    100
              session.gc_maxlifetime    1440    1440
              session.gc_probability    1    1
              session.hash_bits_per_character    4    4
              session.hash_function    0    0
              session.name    PHPSESSID    PHPSESSID
              session.referer_check    no value    no value
              session.save_handler    files    files
              session.save_path    C:\DOCUME~1\PRARTH~1.PC\LOCALS~1\Temp    C:\DOCUME~1\PRARTH~1.PC\LOCALS~1\Temp
              session.serialize_handler    php    php
              session.use_cookies    On    On
              session.use_only_cookies    Off    Off
              session.use_trans_sid    0    0
              I think I had all the configuration setup well. Here's what I have in my file:

              [Session]
              session.save_ha ndler = files
              session.save_pa th = "C:\Temp"
              session.use_coo kies = 1
              session.name = PHPSESSID
              session.auto_st art = 0
              session.cookie_ lifetime = 0
              session.cookie_ path = \
              session.cookie_ domain =
              session.cookie_ httponly =
              session.seriali ze_handler = php
              session.gc_prob ability = 1
              session.gc_divi sor = 1000
              session.gc_maxl ifetime = 1440
              session.bug_com pat_42 = 0
              session.bug_com pat_warn = 1
              session.referer _check =
              session.entropy _length = 0
              session.entropy _file =
              session.cache_l imiter = nocache
              session.cache_e xpire = 180
              session.use_tra ns_sid = 0
              session.hash_fu nction = 0
              session.hash_bi ts_per_characte r = 5

              Comment

              • ak1dnar
                Recognized Expert Top Contributor
                • Jan 2007
                • 1584

                #22
                Originally posted by twinklyblue
                I think I had all the configuration setup well. Here's what I have in my file:

                [Session]
                session.save_ha ndler = files
                session.save_pa th = "C:\Temp"
                session.use_coo kies = 1
                session.name = PHPSESSID
                session.auto_st art = 0
                session.cookie_ lifetime = 0
                session.cookie_ path = \
                session.cookie_ domain =
                session.cookie_ httponly =
                session.seriali ze_handler = php
                session.gc_prob ability = 1
                session.gc_divi sor = 1000
                session.gc_maxl ifetime = 1440
                session.bug_com pat_42 = 0
                session.bug_com pat_warn = 1
                session.referer _check =
                session.entropy _length = 0
                session.entropy _file =
                session.cache_l imiter = nocache
                session.cache_e xpire = 180
                session.use_tra ns_sid = 0
                session.hash_fu nction = 0
                session.hash_bi ts_per_characte r = 5
                Check this line under your php.ini
                session.cookie_ path = /
                in yours its "\"

                Comment

                • twinklyblue
                  New Member
                  • Jun 2007
                  • 37

                  #23
                  Originally posted by ajaxrand
                  Check this line under your php.ini
                  session.cookie_ path = /
                  in yours its "\"
                  ajaxrand.. thank you very much!!! that fixed it.. whew..

                  Comment

                  • ak1dnar
                    Recognized Expert Top Contributor
                    • Jan 2007
                    • 1584

                    #24
                    Originally posted by twinklyblue
                    ajaxrand.. thank you very much!!! that fixed it.. whew..
                    Glad to hear that twinklyblue.See you next time here @ TSDN.

                    Comment

                    Working...