First of all, my siession data can be written to: the session data area or database in the file,
Then how to write the session data in the file or the data area of the session data into the database, or arbitrarily select two different media to write each other,
So the memory mechanism of the session is rewritten.
Objective:
① easy to manage a large number of session data
② facilitates the Web server cluster (that is, multiple Apache servers, because one may not be enough) to share session data. (There can actually be a server dedicated to storing session data, and then there are multiple Web servers, so that multiple Web servers share the concept of the unit session data)
Scheme:
Storage, such as memory,
The following is an experiment with the mechanism of warehousing:
① implementation process: ① defines (implements) storage-related functions. , and then set it to the function that the session mechanism needs to store (in fact, just like the idea of the auto-load function, it tells PHP to use my own definition of this function as my session store function)
Session mechanism, a total of 6 storage functions required
(This order can be disrupted)
The USERSESSIONGC () is a garbage collection function, which is the function that manages those temporary files (data areas).
The stored function of the Session is set by the PHP Session_set_save_handler (start processor, end processor, read processor, write processor, delete processor, garbage collector) function to complete
So that's what it looks like:
(This order cannot be disrupted)
Then, I introduce the file that sets the storage mechanism in my session file:
Be sure to ensure that the session base is open before opening it:
PHP, write session data to unused storage media