I have been checking the PHP session functions and I saw session_abort()
.
What is the purpose of using session_abort()
?
What is the difference between session_abort()
and session_destroy()
?
session_abort()
is analogous to session_write_close().
PHP locks session data during a web request to prevent data corruption on multiple simultaneous requests.
When Request 1 comes in, Session 1 is locked by that process so it can make any changes needed. If Request 2 comes in for Session 1, php blocks until the session lock is released to make sure that Request 2 has the most up-to-date session data.
session_abort()
closes the session and releases the lock without flushing session data to the session storage mechanism while session_write_close()
writes the current content of session back and then closes / releases the lock.
edit: Calling session_abort()
or session_write_close()
will let php process Request 2 even if Request 1 is not finished processing.
session_abort() finishes session without saving data. Thus the original values in session data are kept.
session_destroy() destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie. To use the session variables again, session_start() has to be called.
References :
http://php.net/manual/en/function.session-destroy.php
http://php.net/manual/en/function.session-abort.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With