...

View Full Version : problem with users being logged in



LittleSpy
01-12-2004, 09:41 PM
I have tried a lot of things over the past week to try and keep a users session from being deleted, but it seems that after a few hours the user will be logged out and their old session will not be restored.

I have done the following in my code:



ini_set('session.cookie_lifetime', (60*60*24*365));
ini_set('session.gc_maxlifetime', (60*60*24*365));
ini_set('session.gc_probability', 0);

$expiry = 60*60*24*365; //1 year
setcookie(session_name(),session_id(), time()+$expiry, "/", $cookie_domain, 0);


with not much luck, is there something i am missing?

mordred
01-12-2004, 10:37 PM
From the manual page of ini_set():


The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.

So you temporarily disable the GC for sessions as long as your script runs, and after it finishes, the old settings are restored, and your session get's deleted sometime later.

You need to adjust these settings directly in your php.ini file. Perhaps it's also possible to achieve the desired results through using a .htaccess file, but you may need to set an alternative session_save_path, so your "permanent" sessions do not reside in a directory that gets occasionally sweeped by another PHP application, which uses sessions.

However, I wouldn't do this! Sessions are designed to be only short-lived tokens to identify a client to the server, and to persist data within them. If you need a "permanent" login status for your users, send only a cookie.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum