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.