RE: Session.gc_maxlifetime?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is my understanding;

When you use session_start(); in your script it sets a condition that will
cause a session write of the contents of the $_SESSION array to the session
repository (by default a file whose name contains the session ID) when the
script has ended.  At that time the record timestamp (file last modified
date/time) should be modified or reset to the current time.  To answer your
question below, I believe technically the timestamp is very close to the
script end time for a script containing a session_start() call (not the
actual time of the session_start() call is executed).

Periodically the gc (garbage cleanup) process is invoked, at which time all
sessions whose timestamp is checked to see how old they are and if they
precede the current timestamp minus the gc_maxlifetime value, they are to be
removed from the repository.

Notice that the processing above is accomplished when the script has ended
(sent it's last output to the browser).  By invoking the gc process at this
time it never has a direct impact on the response time or the users
experience, unless they are awfully fast with the mouse.  I have in the past
found that the GC routines are not invoked every invocation of a script, but
rather a "probability" factor causes the GC routine to be invoked on only
some percentage of the calls to session start to avoid adding needless load
to the server (i.e. say 10% of all script executions may trigger a call to
the GC routine).  To offset this I had to make sure that when
session_start() retrieved old session values (session_read), I had to add
checks to make sure I wasn't reading an old session that had expired but had
just not been cleaned up yet.

You can learn a lot about sessions by coding and testing your own
session_handler routines;

http://www.php.net/manual/en/function.session-set-save-handler.php

There are lots of other good tutorials in books on php programming.

Warren Vail


-----Original Message-----
From: Suhas [mailto:psuhas@xxxxxxxxx] 
Sent: Monday, October 04, 2004 9:30 AM
To: php-general
Subject:  Session.gc_maxlifetime?


Hello,

I just want to make sure that I understand this concept.

When i read thr' docs,

session.gc_maxlifetime specifies the number of seconds after which data will
be seen as 'garbage' and cleaned up

and default value is 1440.

My guess is :

A.  1440 seconds from last visit to the page (where session id is used), 
B. 1440 seconds from session_start() function call

My general understanding is a session can be idle for 1440 seconds. If a php
page tried to refer to a session which is been idle more than 1440 seconds,
there is very little chance that page will access to session data.


Can any one please explain or send links or more docs on this?

Thanks in adv,

Suhas

-- 
Suhas Pharkute.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux