.htaccess php_value

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    .htaccess php_value

    I wrote into .htaccess line of code:
    php_value session.gc_maxlifetime 20
    But after 20 seconds session is not destroyed. What problems are can be?

    #2
    Full content of .htaccess file is it:
    php_value session.use_cookies 0
    php_value session.gc_maxlifetime 20
    php_value session.name SID
    = = = = =
    And i have not a access to the php.ini file.

    Comment


      #3
      have you tried to add ini_set(); in to your script?
      like:

      PHP Code:
      ini_set('session.use_cookies',0);
      ini_set('session.gc_maxlifetime',20);
      ini_set('session.name','SID'); 
      to test which value is set do this:
      PHP Code:
      echo ini_get("session.gc_maxlifetime"); 
      there is also another way like
      PHP Code:
      session_cache_expire(1); //1 minute
      session_name("SID"); 
      Advertise your mobile site for FREE with AdTwirl

      Comment


        #4
        Оk, i will try do it..

        Comment


          #5
          = = = = =
          index.php
          = = = = =
          <?php
          ini_set('session.use_cookies',0);
          ini_set('session.gc_maxlifetime',20);
          ini_set('session.name','SID');
          session_start();
          $_SESSION["key"] = "Session alive<br /><br />";
          echo '<a href="another_page.php?'.SID.'">Go to another page</a>';
          ?>
          = = = = =
          the another.page
          = = = = =
          <?php
          session_start();
          if(isset($_SESSION["key"])) {
          echo $_SESSION["key"];
          }
          else {
          echo "Session died<br /><br />";
          }
          echo 'Refresh this page after 25 seconds please to see result ...<br />';
          echo 'Value of session.gc_maxlifetime is "'.ini_get("session.gc_maxlifetime").'"';
          ?>
          This ^ example.
          It's right?
          Does not work...

          Comment


            #6
            And why my profile and profiles of other users on this forum are look like this:
            User Name: 147258a
            User Title: Junior Member
            Last Activity: 03-09-08 05:50
            Your profile is also looks such as above.

            Comment


              #7
              Originally posted by GumSlone View Post
              have you tried to add ini_set(); in to your script?
              like:

              PHP Code:
              ini_set('session.use_cookies',0);
              ini_set('session.gc_maxlifetime',20);
              ini_set('session.name','SID'); 
              to test which value is set do this:
              PHP Code:
              echo ini_get("session.gc_maxlifetime"); 
              there is also another way like
              PHP Code:
              session_cache_expire(1); //1 minute
              session_name("SID"); 
              wow, its luk lyk amazing, but will u give me proper information where i can put this code?

              Comment


                #8
                like any idiot knows lol

                BEFORE YOUR HEADERS OMFG DUDE!!!
                Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
                Visit: WapMasterz Coming Back Soon!
                _______
                SCRIPTS FOR SALE BY SUBZERO
                Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
                FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
                _______
                Info & Tips
                php.net
                w3schools.com

                Comment


                  #9
                  Originally posted by PoV@rEsK View Post
                  = = = = =
                  index.php
                  = = = = =
                  <?php
                  ini_set('session.use_cookies',0);
                  ini_set('session.gc_maxlifetime',20);
                  ini_set('session.name','SID');
                  session_start();
                  $_SESSION["key"] = "Session alive<br /><br />";
                  echo '<a href="another_page.php'.SID.'">Go to another page</a>';
                  ?>
                  = = = = =
                  the another.page
                  = = = = =
                  <?php
                  session_start();
                  if(isset($_SESSION["key"])) {
                  echo $_SESSION["key"];
                  }
                  else {
                  echo "Session died<br /><br />";
                  }
                  echo 'Refresh this page after 25 seconds please to see result ...<br />';
                  echo 'Value of session.gc_maxlifetime is "'.ini_get("session.gc_maxlifetime").'"';
                  ?>
                  This ^ example.
                  It's right?
                  Does not work...
                  you have to include this:
                  PHP Code:
                  ini_set('session.use_cookies',0);
                  ini_set('session.gc_maxlifetime',20);
                  ini_set('session.name','SID'); 
                  to every page.
                  Advertise your mobile site for FREE with AdTwirl

                  Comment


                    #10
                    * * * sessions_including.php * * *
                    <?php
                    ini_set('session.use_cookies',0);
                    ini_set('session.gc_maxlifetime',20);
                    ini_set('session.name','SID');
                    session_start();
                    ?>
                    * * * index.php * * *
                    <?php
                    require("sessions_including.php");
                    $_SESSION["key"] = "Session alive<br /><br />";
                    echo '<a href="another_page.php?'.SID.'">Go to another page</a>';
                    ?>
                    * * * another_page.php * * *
                    <?php
                    require("sessions_including.php");
                    if(isset($_SESSION["key"])) {
                    echo $_SESSION["key"];
                    }
                    else {
                    echo "Session died<br /><br />";
                    }
                    echo 'Refresh this page after 25 seconds please to see result ...<br />';
                    echo 'Value of session.gc_maxlifetime is "'.ini_get("session.gc_maxlifetime").'"';
                    ?>
                    * * * Demo * * *

                    Comment


                      #11
                      It every time outputs that "Session alive" but output of the "Value of session.gc_maxlifetime" is 20. When i come in to another_page.php i wait for 25 seconds then i refresh this page but it still outputs that "Session alive"... why??? Even if I clear cookie and cache. . .

                      Comment


                        #12
                        20 = 20 minutes if im right... my site has sessions active for 1 year lol but logout kills the session using unset()

                        Comment


                          #13
                          Originally posted by ori View Post
                          20 = 20 minutes if im right... my site has sessions active for 1 year lol but logout kills the session using unset()
                          no its seconds

                          this should work:

                          PHP Code:
                          header("Cache-Control: no-cache, must-revalidate");
                          ini_set('session.use_cookies',0);
                          ini_set('session.gc_maxlifetime',20);
                          ini_set('session.gc_probability',1);
                          ini_set('session.gc_divisor',1);
                          ini_set('session.name','SID');
                          session_start(); 
                          Advertise your mobile site for FREE with AdTwirl

                          Comment


                            #14
                            or you can do this too:
                            PHP Code:
                            <?php
                            header
                            ("Cache-Control: no-cache, must-revalidate"); 
                            $session_lifetime 20;
                            ini_set('session.use_cookies',0); 
                            ini_set('session.gc_maxlifetime',$session_lifetime ); 
                            ini_set('session.gc_probability',1); 
                            ini_set('session.gc_divisor',1); 
                            ini_set('session.name','SID'); 
                            session_start(); 
                            ?>
                            * * * index.php * * *
                            PHP Code:
                            <?php
                            require("sessions_including.php");
                            $_SESSION["key"] = "Session alive<br /><br />";
                            $_SESSION["create_time"] = time(); 
                            echo 
                            '<a href="another_page.php?'.SID.'">Go to another page</a>';
                            ?>
                            * * * another_page.php * * *
                            PHP Code:
                            <?php
                            require("sessions_including.php");

                            if((
                            time()-$session_lifetime) > $_SESSION["create_time"]){session_destroy(); @unset($_SESSION);}

                            if(isset(
                            $_SESSION["key"])) {
                            echo 
                            $_SESSION["key"];
                            }
                            else {
                            echo 
                            "Session died<br /><br />";
                            }
                            echo 
                            'Refresh this page after 25 seconds please to see result ...<br />';
                            echo 
                            'Value of session.gc_maxlifetime is "'.ini_get("session.gc_maxlifetime").'"';
                            ?>
                            Advertise your mobile site for FREE with AdTwirl

                            Comment


                              #15
                              GumSlone, your first example is works, and as i found out it will work too:
                              * * * .htaccess * * *
                              php_value session.use_cookies 0
                              php_value session.gc_maxlifetime 20
                              php_value session.gc_probability 1
                              php_value session.gc_divisor 1
                              php_value session.name SID
                              * * * * * * * * *
                              But there is one thing that i can't understand. See below...
                              * * * Demo * * *
                              Last edited by PoV@rEsK; 15.01.10, 17:08.

                              Comment

                              Working...
                              X