Session usage in PHP's large Web applications

Source: Internet
Author: User
Tags array bool garbage collection session id

At this point, the function bool Session_set_save_handler (callback open, callback close, callback read, callback write, callback destroy, CALLB ACK GC) is the solution provided to us to solve this problem.
The function uses the following 6 functions:
1. bool Open () for opening session storage mechanism,
2. BOOL Close () closes the session store operation.
3. Mixde read () Use this function when the session data is mounted from storage
4. BOOL Write () writes all data for a given session ID to the store
5. bool Destroy () destroys data associated with the specified session ID
6. BOOL GC () garbage collection of data in the storage system
For example, see the PHP manual Session_set_save_handler () function.
If you are working with a class, you can use
Copy Code code 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 6 static methods in the ClassName class. ClassName can swap objects without invoking static methods, but with static members without generating objects, performance is better.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.