www.webdeveloper.com
Results 1 to 8 of 8

Thread: How to increase the Session timeout limit in PHP

  1. #1
    Join Date
    Nov 2004
    Location
    Bangalore, India
    Posts
    71

    How to increase the Session timeout limit in PHP

    Hi,

    If there any way to increase the Session time out limit in php.

    As I have a problem some page in my code takes more than 1 hr to modify, and after when I press save, it does not work.

    I need to set it to 8 Hrs. Pls suggest.

    Thanks
    Siva

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    I haven't tested this out, but based on my understanding, this should do the trick:
    PHP Code:
    session_set_cookie_params(8*60*60);
    session_save_path('/some/path/unique/for/this/set/of/scripts');
    ini_set('session.gc_maxlifetime''28800');
    session_start();
    # rest of script... 
    Note: make sure the directory specified in session_save_path() is writeable by the PHP user.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Sep 2006
    Posts
    643

    Question

    Quote Originally Posted by NogDog View Post
    I haven't tested this out, but based on my understanding, this should do the trick:
    PHP Code:
    session_set_cookie_params(8*60*60);
    session_save_path('/some/path/unique/for/this/set/of/scripts');
    ini_set('session.gc_maxlifetime''28800');
    session_start();
    # rest of script... 
    Note: make sure the directory specified in session_save_path() is writeable by the PHP user.

    Hi

    Question: Do we have to put the code ini_set('session.gc_maxlifetime', '28800'); in all our php pages or just on the login page will do?


    Thanx

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    It would need to be in each file that uses sessions if you do it that way. Of course, it would be easier to put (and the cookie setting, too), into your PHP config file (php.ini) or a local .htaccess file if allowed.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Sep 2006
    Posts
    643
    ok thanx for your kind reply.

  6. #6
    Join Date
    Sep 2010
    Posts
    21
    i have some codes for uploading using php & party third that is flash. i try to upload with max size of 2mb to summerhost, but not work. pls help me!
    i get suggest that config via .htaccess file something like this:
    --------------------------------------
    php_value upload_max_filesize 10M
    php_value post_max_size 10M
    php_value max_execution_time 300
    --------------------------------------
    But still not work in server
    Pls, suggest me.

  7. #7
    Join Date
    Jun 2012
    Posts
    1

    Thumbs up Increase the session timeout

    Hi,

    Am also facing this same problem, Am trying to increase the session timeout.Please make me understand in the following code

    session_save_path('/some/path/unique/for/this/set/of/scripts');

    is this code really required, if yes please tell me why we need to use this code and how do we build the path.

    Thanks
    Vijay

  8. #8
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    Quote Originally Posted by vizay25687 View Post
    Hi,

    Am also facing this same problem, Am trying to increase the session timeout.Please make me understand in the following code

    session_save_path('/some/path/unique/for/this/set/of/scripts');

    is this code really required, if yes please tell me why we need to use this code and how do we build the path.

    Thanks
    Vijay
    You only need it if other sites or pages within your site might be sharing the same PHP session data directory, in order to keep those other sites' or pages' session data clean-up times from impacting your times.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles