p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Session Question


Message #1 by Empier4552@a... on Mon, 28 Oct 2002 12:01:39 EST
I have a site using sessions. However when the browser is closed or after a 
time limit expires the session shoudl destroy itself. Does it by default 
destroy itself when the browser is closed and if not how can I get it to do 
so? additionally how can I set a time limit style one in which theres a 
timelimit for the session?

Message #2 by "Nikolai Devereaux" <yomama@u...> on Mon, 28 Oct 2002 12:30:23 -0800
> I have a site using sessions. However when the browser is closed or after a
> time limit expires the session shoudl destroy itself. Does it by default
> destroy itself when the browser is closed and if not how can I get it to do
> so?

The session remains open as long as at least one window of the browser instance
is still open.  The session is destroyed either when you call
session_destroy(), the user closes all windows from that browser instance, or
the time limit is up.


> additionally how can I set a time limit style one in which theres a
> timelimit for the session?

look in php.ini under the session header.  There should be a lifetime setting
for garbage collection.  If an open session is unmodified for that lifetime,
then it's flagged for being deleted the next time the PHP garbage collector
happens to run and clean things up.

You don't have control over when that happens, though, but it's frequently
enough.


If you use custom session handlers, you can enforce more strict expiration
handling in your session_open() and session_read() handlers.


Take care,

nik

Message #3 by "Nikolai Devereaux" <yomama@u...> on Mon, 28 Oct 2002 12:33:28 -0800
I should add that the PHP documentation page for sessions answers all your
questions:

http://www.php.net/manual/en/ref.session.php



  Return to Index