mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
Add some general information about custom session save handlers relating to the session workflow.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@323385 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
c36d6e4eaf
commit
bd0cecd508
1 changed files with 34 additions and 0 deletions
|
@ -243,6 +243,40 @@ here</a>.
|
|||
will need to use <function>session_set_save_handler</function> to
|
||||
create a set of user-level storage functions.
|
||||
</para>
|
||||
<para>
|
||||
The callbacks specified in <function>session_set_save_handler</function> are methods
|
||||
called by PHP during the life-cycle of a session: open, read, write and close and for
|
||||
the houskeping tasks of deleting stored sessions and periodic garbage collection.
|
||||
</para>
|
||||
<para>
|
||||
Therefor, PHP always requires session save handlers. The default is usually the
|
||||
internal 'files' save handler, but can be overriden using
|
||||
<function>session_set_save_handler</function> if you need anything other than PHP's
|
||||
internal handlers. Alternative internal save handlers can also be provided by PHP extensions,
|
||||
such as sqlite, memcache and memcached.
|
||||
</para>
|
||||
<para>
|
||||
When the session starts, PHP will call the open() handler followed by the read() handler
|
||||
which should return an encoded string extactly as it was originally passed for storage.
|
||||
Once the read() handler returns the encoded string, PHP will decode it and then populate
|
||||
the resulting array into the $_SESSION superglobal.
|
||||
</para>
|
||||
<para>
|
||||
When PHP shuts down (or when <function>session_write_close</function> is called),
|
||||
PHP will encode the $_SESSION superglobal into a specially serialized string and pass this
|
||||
along with the session ID to the the write() callback.
|
||||
After write() PHP will invoke the close() handler.
|
||||
</para>
|
||||
<para>
|
||||
When a session is specifically destroyed, PHP will call the
|
||||
destroy() handler with the session ID.
|
||||
</para>
|
||||
<para>
|
||||
PHP will call gc() from time to time to expire any session
|
||||
records according to the set max lifetime of a session. This routine
|
||||
should delete all records from persistent storage which were last
|
||||
accessed longer than the $lifetime.
|
||||
</para>
|
||||
</section>
|
||||
</appendix>
|
||||
|
||||
|
|
Loading…
Reference in a new issue