Custom Session HandlersTo implement database storage, or any other storage method, you will need to use session_set_save_handler to create a set of user-level storage functions. As of PHP 5.4.0 you may create session handlers using the SessionHandlerInterface or extend internal PHP handlers by inheriting from SessionHandler.
The callbacks specified in session_set_save_handler are methods
called by PHP during the life-cycle of a session:
Therefore, PHP always requires session save handlers. The default is usually the
internal 'files' save handler. A custom save handler can be set using
session_set_save_handler. Alternative internal save handlers are also
provided by PHP extensions, such as
When the session starts, PHP will internally call the
When PHP shuts down (or when session_write_close is called),
PHP will internally encode the $_SESSION superglobal and pass this
along with the session ID to the
When a session is specifically destroyed, PHP will call the
PHP will call the |