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

Jul 13, 2016 pm 05:25 PM
php session use beginner exist common problem of meet

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_...
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

See all articles