session.save_path

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
anthonynz
Forum Newbie
Posts: 2
Joined: Sun Jul 03, 2011 4:07 am

session.save_path

Post by anthonynz »

Greetings. My hosted session seems to timeout earlier than I wish, and I think it is because we dont have our own session path on the Hosted network.

I have now set the following in our /html .htaccess file
php_value session.gc_maxlifetime 7200
php_value session.save_path "/home/.../...../html/_tmp"

Now when I run /info I see these are my local settings, but even though people are on, I am not seeing any entries in the _tmp directory.
Can someone tell me if this means I have the path incorrect and it is still saving to the default?
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: session.save_path

Post by McInfo »

Try session_save_path().

It is best to save the session files in a directory outside the document root, but if you are unable to do that, password-protect the directory with a .htaccess file using digest, or at least basic, authentication.

As an alternative, consider saving session data in a database. See session_set_save_handler().
anthonynz
Forum Newbie
Posts: 2
Joined: Sun Jul 03, 2011 4:07 am

Re: session.save_path

Post by anthonynz »

Thank you for your reply. I have changed it to session_save_path but that made no difference.

Neither setting gives me any errors, but I am assuming that I should see some files in the /_tmp directory when I log on, and it remains empty. (is this correct?)

Is it anything to do with session_start?(Excuse my ignorance - I do not know how this all operates)
This is in a file (session.inc) that is included in every page, and has the following
($SessionSavePath='/home/bentra/bentra.co.nz/html/_tmp/'; is set in a previously included config.php)

if (isset($SessionSavePath)){
session_save_path($SessionSavePath);
}
session_start();
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: session.save_path

Post by McInfo »

anthonynz wrote:I am assuming that I should see some files in the /_tmp directory when I log on[...]. (is this correct?)
Yes. If the save path is in fact set to that directory, files should appear there when sessions are started.
anthonynz wrote:Is it anything to do with session_start?
Other than it being required for the session to work, no.

Contact your server administrator. They should know more about the server configuration and what the problem and solution might be.
Post Reply