Actually, there's nothing you have to do in code to accomplish that. All that can be done through configuration of php.ini
Three PHP settings control session existence-time: session.cookie_lifetime, session.gc_maxlifetime, and session.gc_probability
Every time PHP runs session_start() (or every time a script is run if session.auto_start is set to 1), it generates a random integer between 1 and 100. If that number is equal to or less than the value of session.gc_probability, it performs garbage collection on the session store.
What PHP considers garbage is set by session.gc_maxlifetime. If any session store is older than the number of seconds in session.gc_maxlifetime, then when PHP's garbage collection activates, that session store is removed.
So setting session.gc_maxlifetime to 900 and sessoin.gc_probability to 100 should enforce absolutely expriation of sessions.
Determining how long the session's index cookie should be kept by the browser is set by session.cookie_lifetime. By default, it's set to 0, which tells the browser to delete the cookie when the browser is shut down.
Want the best answers? Ask the best questions: TANSTAAFL!!