Solution to the problem that the php session disappears after refreshing: 1. Open the session through "session_start();"; 2. Write all public configurations in a php file; 3. The variable name cannot be the same as the array The labels are the same; 4. Check the storage path of the session data in phpinfo, and check whether the sessio in the file directory is saved successfully.
The operating environment of this tutorial: Windows 10 system, PHP version 8.1, DELL G3 computer
Why is the php session gone after refreshing? manage?
ESSIONThe value becomes empty after refreshing the page, and the SESSION value cannot be obtained
1. The page using session must open session, that is, session_start();
2. If you want several pages to use a session together, then these pages must have an associated file to obtain the same session_id, so that the only session can be determined, so in the project, it is best Write all the public configuration in a PHP file, such as database configuration, session_satrt(), jump when not logged in, etc., and then reference it on other pages to get the same session.
3. Also note that the variable name cannot be the same as the array subscript, so that the session value will be cleared after refreshing the page, such as $user=$_SESSION['user']['name']. is wrong, the named variable cannot be the same as the session subscript.
4. If the problem still cannot be solved, you can check the storage path of the session data in phpinfo and check whether the sessio in the file directory is saved successfully.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What should I do if the php session disappears after refreshing?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools
