Home > Backend Development > PHP Tutorial > Frequently asked questions when using SESSION for the first time_PHP tutorial

Frequently asked questions when using SESSION for the first time_PHP tutorial

WBOY
Release: 2016-07-13 17:25:04
Original
917 people have browsed it

Maybe every PHP beginner will encounter the same problem when using SESSION, which 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, nor is it a syntax error, but the path specified by PHP to store the SESSION file does not exist. The following is about the usage of SESSION and some of my first experience. I hope beginners will avoid taking some detours.

PHP’s SESSION information is written on the server’s hard disk. By default, it is the /TMP directory. If there is no such directory on your hard disk, the error message mentioned above will appear. Here are some suggestions for this There are two solutions: one is to create a directory called TMP on 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 handle SESSION differently. ASP writes the SESSION to the client, uses a special statement when calling, and does not do other processing, while PHP also initializes an environment for the SESSION. Next, I will give an introduction to PHP's SESSION.

Before using SESSION, you must first initialize it with session_start(), and declare variables with the session_register() function. The format should be session_register("ssp") or session_register("$ssp"). If the declaration is successful, Will return a TRUE value. In this way, this variable becomes a SESSION and can be called in other pages.

The calling method is as follows: SESSION must also be initialized on the calling page (same as above), and then the variable name can be used directly,



session_start: initial session.
session_destroy: End session.
session_name: access the current session name.
session_module_name: access the current session module.
session_save_path: access the current session path.


session_id: access the current session code.
session_register: Register new variables.
session_unregister: Delete registered variables.
session_is_registered: Check whether the variable is registered.
session_decode: Session data decoding.
session_encode: Session data encoding

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532088.htmlTechArticlePerhaps every PHP beginner will encounter the same problem when using SESSION, which is Warning: open (/tmp/sess_7a8c81039d7cba3f9a868bc90f821526, O_RDWR) failed: m (2) in YOUR_...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template