|
Posted by Juha Suni on 12/09/05 16:27
Atte Andrι Jensen wrote:
> Hi
>
> I'm developing a site where I'd like to store information during a
> users visit. So far I've been using sessions, but as far as I can
> tell it's not possible to control for how long a session is valid. It
> seems that
> these information are valid until the browser closes.
>
Sessions use cookies. The cookies are used to store the users Session ID.
These cookies by default have their lifetime set to 0 (meaning that the
cookie expires when the browser is closed). You can change this from php.ini
with session.cookie_lifetime, or using the
session_set_cookie_params -function from within the script.
See
http://www.php.net/session
and
http://www.php.net/manual/en/function.session-set-cookie-params.php
Please note that these settings only affect the cookie. While the cookie
might persist in the browser (if it is kept open for a long time), the
actual session data stored on the server might be gone. By default the PHP
garbage collection clears up sessions that have not been used for 24
minutes. To change sessions lifetimes use session.gc_maxlifetime in php.ini.
Please note that even this might not be enough if some other scripts, with
smaller timeouts, use the same folder for storing the session data (Their
garbage collection would trash session files in the folder according to
their timeout rules). To avoid this, you would need to set the script to use
a different session save path (session.save_path).
Usually sessions are all you need. Setting the session timeout to higher
than 24 minutes takes a few steps but is not a problem.
HTH
--
Suni
Navigation:
[Reply to this message]
|