Frequently asked questions about the first SESSION

Source: Internet
Author: User
Every PHP beginner may encounter the same problem when using SESSION, that is, Warning: open (/tmp/sess_7a8c81039d7cba3f9a868bc90f821526, O_RDWR) failed: m (2) inYOUR_PHP_FILE_PATHsession.phponline2 this is not your PHP version

Every PHP beginner may encounter the same problem when using SESSION, that is
Warning: open (/tmp/sess_7a8c81039d7cba3f9a868bc90f821526, O_RDWR) failed: m (2) in YOUR_PHP_FILE_PATHsession.php on line 2

This is not because your PHP version is not high enough, not a syntax error, but the path specified by PHP to store SESSION files does not exist. The following describes the usage of the SESSION and some of my first-time experiences. I hope that beginners will take less detours.

The SESSION information of PHP is written on the server's hard disk. by default, it is the/TMP Directory. if this directory is not found on your hard disk, the error information mentioned above will appear, there are two solutions to this problem. one is to create a directory named TMP in the root directory, and the other is to use the session_save_path () function provided by the system to re-specify an existing directory. PHP and ASP process sessions in different ways. ASP writes sessions to the client and uses a special statement to call the SESSION. PHP also needs to initialize an environment for the SESSION. Next I will introduce the PHP SESSION.

Before using SESSION, you must first initialize session_start () and declare the variable using the session_register () function. the format should be session_register ("ssp") or session_register ("$ ssp "), if the statement is declared successfully, a TRUE value is returned. This variable becomes a SESSION and can be called on other pages.

The call method is as follows: you must initialize the SESSION on the call page (same as above), and then you can directly use the variable name,



Session_start: initial session.
Session_destroy: ends the session.
Session_name: name of the current session to be accessed.
Session_module_name: Access the current session module.
Session_save_path: the current session path.


Session_id: Access the current session code.
Session_register: registers a new variable.
Session_unregister: Delete a registered variable.
Session_is_registered: Check whether the variable is registered.
Session_decode: decodes Session data.
Session_encode: Session Data encoding

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.