RE: [PHP] session life
| From: | John W. Holmes | Date: | Sun, 22 Dec 2002 18:05:43 +0000 |
| Subject: | RE: [PHP] session life | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129118@lists.php.net to get a copy of this message | ||
> On Sat, 2002-12-21 at 08:03, John W. Holmes wrote:
> > > I'm setting a session with
> > > session_set_cookie_params (time()+6480000);
> > > so the cookie should last 70 days+ but the data wasn't
> > > returned.
> > >
> > > from looking in the manual i see that session_cache_expire is used
to
> > set
> > > or print the current value of the expire. Its set in php.ini by
> > default to
> > > 180 minutes.
> > >
> > > So it seems that the garbage collector will clean up the session
file
> > > after 180 mins or 10800 seconds which is less then i was expecting
> > after
> > > setting the cookie life.
> > >
> > > do i need to set
> > >
> > > session_set_cookie_params (time()+6480000);
> > > session_cache_expire (6480000);
> > >
> > > for the data to still be available if the user returns during the
> > cookies
> > > life and is this on a per session basis.
> >
> > Well, first of all, session cookies are deleted when the user closes
> > their browser. So unless the user is leaving the browser open for 70
> > days, this setting won't matter.
>
> This is incorrect, by default session cookies have a lifetime of 0
which
> means they are peresistent until the browser is closed. If you set
the
> ini directive session.cookie_lifetime to something other than 0, for
> example 86400 then the session will for the number of seconds
specified,
> in this case 1 day, even after the browser has been closed.
Okay, I should have known that, but thanks for pointing it out. So for
the original question, you would want to increase the
session.gc_maxlifetime to match the session.cookie_lifetime, right?
Otherwise the cookie will persist but the data within the session will
be erased.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/