×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Sessions

The events that take place when you issue session_start() in your script. by sleipnir214
Posted: 4 Mar 04

Then you issue session_start() in your code, a number of things happen in quick succession:
  1. PHP determines whether session garbage-collection must take place:
    1. PHP divides the value of the runtime configuration setting "session.gc_probability" by the value of the runtime configuration setting "session.gc_divisor".  (The default value for session.gc_probability is 1.  The default value for session.gc_divisor is 100.)
    2. PHP generates a random number.
    3. If the random number is smaller than the calculated quotient, garbage-collection activates
  2. If garbage collection is to take place, PHP checks all files in the directory specified by the runtime configuration setting "session.save_path".  It is looking for all files older than the number of seconds in the runtime configuration setting "session.gc_maxlifetime".  All files older than that number of seconds are deleted.
  3. PHP then checks to see whether a cookie named the same as the runtime configuration setting "session.name" was sent by the browser.
    1. If the cookie exists, PHP fetches the value of that cookie.  That value is the current session id.
    2. If the cookie does not exist, PHP generates a session id and sets a cookie named as specified in "session.name".  The value of that cookie is the generated session id.
  4. If a session cookie with a session id was sent by the user's browser, PHP will look in the directory specified by "session.save_path".  It is looking for a file named "sess_" plus the session id.
    1. If that file is found, PHP reads the session data stored there and populates $_SESSION.
    2. If the file is not found, PHP initializes $_SESSION as empty

Back to PHP FAQ Index
Back to PHP Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close