Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts

    Increasing Session length

    I need to increase the session length but nothing I've tried has worked. This is on a vps so while technically its a shared server, I don't think it should suffer from the problems associated with shared servers. Also the site is new (still under development) and so has negligible traffic.

    gc_maxlifetime is set to 0 (I read on php.net this would make the session last til the browser was closed)
    gc_divisor = 100
    gc_probability = 0

    Is there something else I should be setting? (Basically, the client just spent 40 minutes filling in a form, only to be bounced back to login)

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,151
    Thanks
    2
    Thanked 335 Times in 327 Posts
    The first one should be session.cookie_lifetime (setting gc_maxlifetime to zero would cause all session data files to be deleted every time GC runs.)

    Setting gc_maxlifetime to a longer value should work. As long as the session.save_path points to a folder that only your instance of the VPS uses, your gc_maxlifetime setting should apply. How are you setting these and have you verified their actual runtime values using a phpinfo(); statement?

    Setting gc_probability = 0 should stop GC (I don't recall if the code use less-than < or less-than and equal-to <= in the comparison.)

    It could be that sessions are not working at all.

    Edit: I looked at the C source code again and the GC logic use less-than <, so, setting gc_probability = 0 does stop GC.
    Last edited by CFMaBiSmAd; 05-14-2008 at 03:34 PM.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    you could just do <&#37; Server.ScriptTimeout = 1000 %>

    where 1000 = how many seconds you want to allow

  • #4
    New Coder
    Join Date
    Mar 2008
    Location
    Somerset, England
    Posts
    93
    Thanks
    0
    Thanked 10 Times in 10 Posts
    Quote Originally Posted by runnerjp View Post
    you could just do <% Server.ScriptTimeout = 1000 %>

    where 1000 = how many seconds you want to allow
    VB isn't really going to help in a PHP script is it now.

  • #5
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    cookie_lifetime =0

    sessions are definitely working. The session still times out <1 hour (I'm going to time how long it is)

  • #6
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    ok what about someting liek this
    PHP Code:
    <?php
     
    // Get the current Session Timeout Value
        
    $currentTimeoutInSecs ini_get('session.gc_maxlifetime');
            echo 
    "\nDefault timeout = ".$currentTimeoutInSecs." seconds\n";

        
    // Change the session timeout value to 30 minutes
        
    ini_set('session.gc_maxlifetime'30*60);
        
    $currentTimeoutInSecs ini_get('session.gc_maxlifetime');
            echo 
    "Altered timeout = ".$currentTimeoutInSecs." seconds\n";
       
    session_start();
    ?>

    session_start needs to be below for it to effect that session

  • #7
    Regular Coder
    Join Date
    Apr 2008
    Location
    New Jersey
    Posts
    116
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Setting session.cookie_lifetime = 0 isn't going to help if your session.gc_maxlifetime is still 0. You'll need to set session.gc_maxlifetime to something reasonably high. 86400 (1 day) may be appropriate.

    If that still doesn't work, I've sometimes found my session lifetime settings being defeated by session cleanup scripts that fail to acknowledge my session.gc_maxlifetime (cron jobs that have their own setting that also has to be changed, rather than pulling the value out of php.ini). Investigating that will require digging into what your system is doing about session cleanup.
    Chaos
    Lost Souls: text based RPG | MUDseek: MUD gaming search | MUDfind: MUD resource sites | Discordian Quotes

  • #8
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    Turns out it was some special debian thing.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •