Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lengthening PHP sessions

Status
Not open for further replies.

TheDust

Programmer
Aug 12, 2002
217
US
I have searched wide and low for a solution on how to extend PHP sessions because I've built an application that demands users stay logged in all day, basically. I don't have access to change the php.ini settings because it is hosted with a third party. I've found a number of different scripts out there that utilize session_set_save_handler() to use custom session handlers to save session data in MySQL, but I've had bad results. The sessions act as before only when a user gets timed out, he/she can't log in anymore. You have to close out all browsers and then log in... then it will work again... until the session times out once again.

Here are two scripts that I have tried out:


Does anyone have a reccomended way to deal with this problem? It's very annoying.
 
Why not use cookies? The third parameter of the setcookie function lets you determine when the cookie will expire.
 
All of PHP's session-handling settings (listed in table 1 here) are listed as having a changeability of PHP_INI_ALL. This means that you can tweak those settings from php.ini, a .htaccess file, or from withing a script using ini_set().

The session-handling settings are described in faq434-4908. You can probably set your session settings as you need.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
748323 -
I am trying to use cookies, but no luck thus far. Here's the code I'm using - am I doing this all wrong?

Code:
$expireTime = 60*60*8; // 8 hours
session_set_cookie_params($expireTime);
session_start();

sleipnir214 -
I have tried using ini_set in the past, but I think the server admins somehow changed their installation of PHP so that those session variables are unable to be overwritten - is that possible??
 
sleipnir214 - The ini_set() setting I include in the code don't throw an error... they simply do not take.

I'll check out that link, jpadie... still no luck with this issue...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top