The session of PHP

Source: Internet
Author: User

The session is stored on the server side and saved in a file or database.

By default, the session set in PHP.ini is saved by files (Session.save_handler = files), that is, the session data is saved using a read-write file, and the directory saved by the session file is SESSION.S AVE_PATH specifies that the file name is prefixed with Sess_, followed by the SESSION ID, such as: sess_c72665af28a8b14c0fe11afe3b59b51b. The data in the file is the SESSION data after the serialization.

If the access volume is large, may produce the session file will be more, then you can set the hierarchical directory to save the session file, the efficiency will be improved a lot, the setting method is: Session.save_path= "N;/save_path", N is a graded series, save _path is the starting directory.

When the session data is written, PHP will obtain the client's session_id, and then according to the session ID to the specified session file to save the directory to find the corresponding session file, does not exist to create, and finally to serialize the data to write to the file. Reading session data is a similar process, and the data that is read needs to be deserialized to generate the corresponding session variables.

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.