Page 1 of 1

session.save_path

Posted: Sun Jul 03, 2011 4:32 am
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?

Re: session.save_path

Posted: Sun Jul 03, 2011 4:17 pm
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().

Re: session.save_path

Posted: Sun Jul 03, 2011 7:28 pm
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();

Re: session.save_path

Posted: Mon Jul 04, 2011 12:40 am
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.