Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6838857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:38:52+00:00 2026-05-26T23:38:52+00:00

My Problem is quickly described by the need to extend the session data life

  • 0

My Problem is quickly described by the need to extend the session data life over it’s default settings within the php.ini without changing the php.ini. I am looking for a solution that can be applied to a number of different php setups across server platforms so there is no need for the script to be changed for every install.

Since I don’t want to change defaults on my server and want to stay as independent as possible with my script I am looking for a way to exceed the default 1440 seconds that are set for the garbage collector to dispose of my session data prematurely.
Simply setting ini_set('session.gc_maxlifetime',36000);
to 10 hours will not work as on some servers the GC will run unaffected by php’s settings and delete my sessions after 24min anyway as described here.
To get around this problem the author suggests to change the session.save_path to another folder unaffected by the os’s gc and thereby enforcing the set session.gc_maxlifetime to my settings.
Unfortunately I was unable to create a temp folder within php’s tmp space and though I like to I don’t seem to be able to since I don’t have 0600 access on most servers.

One solution would be to link my session data to my own folder created right in my shared host folder but that seems insecure as this folder must then be available online and therefor exposed to possible id theft.
Though I do not know whether that is the case.

Another solution would be to include $_SESSION["stayalaive"]=time(); since the gc only deletes sessions untouched for the specific amount of time to the login script so that the session will be extended every time the login script is called though that means if the user does not click anything for 24min the session will be deleted anyway which is something I could possibly live with but it also seems to put on another process that seems unnecessary.

So my question is how to set up my session data to stay alive for 10 hours without clocking too much performance for it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:38:52+00:00Added an answer on May 26, 2026 at 11:38 pm

    I have used php.ini directives inside scripts before and besides you can make directories inside your hosting reserved space.

    So (at the very beginning of your script) this must be work, no doubt:

    <?php
    
        // obtain current directory
        $APPPATH = dirname(__FILE__); 
    
        if ( ! file_exists($APPPATH . '/tmp/sessions'))
        {
            mkdir($APPPATH . '/tmp/sessions', 0700, TRUE);
        }
    
        ini_set('session.save_path', $APPPATH . '/tmp/sessions');
        ini_set('session.gc_maxlifetime', 36000);
        session_start();
    
    ?>
    

    Both directives have PHP_INI_ALL changeable mode, so can be set inside scripts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem I have timestamped data, which I need to search based on the timestamp
I have a problem drawing something quickly in .NET. I don't think that any
I had a problem that was partially solved. To explain it quickly : I
Problem is described and demonstrated on the following links: Paul Stovell WPF: Blurry Text
Zend Gurus: I have a problem that my session expires if I refresh a
Problem I need a key-value store that can store values of the following form:
I decided to try project euler problem 17 today, and I quickly wrote a
I've started using HTML5 and WebSQL, and I quickly ran into a problem: all
I have a problem retrieving items from a fairly large list. I can quickly
I am trying to quickly solve the following problem: f[r_] := Sum[(((-1)^n (2 r

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.