This topic is locked

Session expiry question?

2/17/2009 8:14:17 AM
PHPRunner General questions
N
nix386 author

Hello fellow phprunners! Need some help with this as I am unsure of the best way forward; as mentioned I currently sharing a server with other customers and php.ini is setup in such a way that it cannot be changed. Session expiry is set in php.ini to 120 which seems far too short as users are getting upset with having to re-login and get to the page they where last viewing/editing etc.. It's possible to add session_set_cookie_params(2400) to every page in output folder but is there a way to include this into the source so I don't have to add this every build (I have a stack of pages 50+)?
Is there a better solution for setting this function?
As always thanks allot.
Nick

hichem 2/17/2009

PHPR uses smarty templating engine and allows caching each page with different settings.

If you open any of the generated list or search or chart pages, you will find

header("Expires: Thu, 01 Jan 1970 00:00:01 GMT");

If you look under source folder (PHP installation folder) you will find a number of files containing the same expiry setting, so I think you would have to change it on list.php for example so that it propagtes to all created list pages.

I don't know if there is a way to set it in one place only (instead of changing all files referring to this setting under source folder)
May be Jane can help with indicating the best way to set the caching, say for example if one would want a page to be cached for 15 minutes?

hichem 2/17/2009

Found this function

function setExpires($expires) {

header(

'Expires: '.gmdate('D, d M Y H:i:s', time()+$expires).'GMT');

}

setExpires(10);

N
nix386 author 2/18/2009

Found this function

function setExpires($expires) {

header(

'Expires: '.gmdate('D, d M Y H:i:s', time()+$expires).'GMT');

}

setExpires(10);


Hey thanks for the response, I understand it better now.. So if i replace the previous code for this expiry to this function it may work...looking into this now.

hichem 2/18/2009

Found this function

function setExpires($expires) {

header(

'Expires: '.gmdate('D, d M Y H:i:s', time()+$expires).'GMT');

}

setExpires(10);


Let me know if this worked for you pls Nick.
Jane, is this the correct way of doing this? what source pages need to be changed to avoid having to change the output files?

Many thanks

Hichem

Sergey Kornilov admin 2/19/2009

If you still need to increase session timeout put php.ini to your home directory or use ini_set() function to change this parameter. Contact your web hosting support team for more info specific to their web server.
Sample syntax:

ini_set("session.gc_maxlifetime", 60*60);
To the best of my knowledge header('Expires ... applies to browser cache and has nothing to do with session timeout.

hichem 2/19/2009

Sample syntax:

ini_set("session.gc_maxlifetime", 60*60);
To the best of my knowledge header('Expires ... applies to browser cache and has nothing to do with session timeout.


You are correct Sergey, my mistake I was looking at browser cache and mixed the two topics.

session.gc_maxlifetime is the place to set this up.

thanks

Hich