Home  >  Article  >  Backend Development  >  The use of session in PHP large-scale web applications_PHP tutorial

The use of session in PHP large-scale web applications_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:28:07715browse

At this time, the function bool session_set_save_handler (callback open, callback close, callback read, callback write, callback destroy, callback gc) provides us with a solution to this problem.
The six functions used by this function are as follows:
1. bool open() is used to open the session storage mechanism,
2. bool close() closes the session storage operation.
3. mixde read() Use this function when loading session data from storage
4. bool write() writes all data for the given session ID to storage
5. bool destroy() destroys the data associated with the specified session ID
6. bool gc() for Garbage collection of data in the storage system
For an example, see the session_set_save_handler() function in the PHP manual.
If you use a class to process it, use

to copy the code The code is as follows:

session_set_save_handler(
array('className','open'),
array('className','close'),
array('className' ,'read'),
array('className','write'),
array('className','destroy'),
array('className','gc'),
)

Call the 6 static methods in the className class. className can change objects without calling static methods, but using static members does not require generating objects, and the performance is better.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323630.htmlTechArticleAt this time, the function bool session_set_save_handler ( callback open, callback close, callback read, callback write, callback destroy, callback gc ) is to provide us with a solution to this problem...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn