|
PHP5中文手册
session_set_save_handler(PHP 4, PHP 5) session_set_save_handler — Sets user-level session storage functions 说明
bool session_set_save_handler
( callback $open
, callback $close
, callback $read
, callback $write
, callback $destroy
, callback $gc
)
session_set_save_handler() sets the user-level session storage functions which are used for storing and retrieving data associated with a session. This is most useful when a storage method other than those supplied by PHP sessions is preferred. i.e. Storing the session data in a local database. 参数
返回值如果成功则返回 TRUE,失败则返回 FALSE。 范例
Example#1 session_set_save_handler() example The following example provides file based session storage similar to the PHP sessions default save handler files . This example could easily be extended to cover database storage using your favorite PHP supported database engine.
<?php 注释Warning
As of PHP 5.0.5 the write and close handlers are called after object destruction and therefore cannot use objects or throw exceptions. The object destructors can however use sessions. It is possible to call session_write_close() from the destructor to solve this chicken and egg problem. Warning
Current working directory is changed with some SAPIs if session is closed in the script termination. It is possible to close the session earlier with session_write_close(). |