Reputation: 827
My understanding is that when a request is received, the Apache server will fork a new process and invoke the appropriate php script/file.
What happens when the session started by the php script, in this new process forked by Apache, has expired or the user has ended it by closing their browser ? There is an exit();
call after errors or logout redirects that I use but I am unsure of what it does at the Server/OS level.
Does Apache kill the process ? How does the communication between apache and php work ?
Upvotes: 0
Views: 377
Reputation:
My understanding is that when a request is received, the Apache server will fork a new process and invoke the appropriate php script/file.
This is only the case for PHP-CGI configurations, which are not typical. Most deployments use the mod_php SAPI, which runs PHP scripts within the Apache process.
What happens when the session started by the php script, in this new process forked by Apache, has expired or the user has ended it by closing their browser ?
Nothing.
In PHP-CGI configurations, the process exits as soon as your script finishes generating a response. In mod_php configurations, the Apache process returns to listening for new requests when your script finishes.
The lifetime of sessions is not tied to any specific process. Keep in mind that sessions are stored as files in your system's temporary directory -- PHP periodically checks this directory for sessions which have expired and removes them as appropriate.
Closing your browser does not remove the session from the server's temporary directory. It may cause your browser to discard the cookies related to the session, causing the session to stop being used, but the server is not notified of this.
Upvotes: 2