phpfunctionsession

Purpose of session_abort()


I have been checking the PHP session functions and I saw session_abort().


Solution

  • 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.

    Calling session_abort() or session_write_close() will let php process Request 2 even if Request 1 is not finished processing.