php7 Solution to the problem that the session cannot be saved: 1. Open the corresponding PHP code file; 2. Modify and use the "session_set_save_handler" function.
The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.
php7 What should I do if the session cannot be maintained?
The impact of php upgrading to php7. ##A recent project will use php7.
Because I use WeChat to log in, I can’t see the debugging information very intuitively. I can only add various terminals and write log textFinally, the thing that vomits blood is that the session is not written normally. Enter, resulting in the session not existing when the page is refreshed for the second time.
By the way, add a sentence, this situation is suitable for the session to be written to the database. If the session is in the form of a file, it should not be affected.
That is, this function session_set_save_handler is used. (Although I have a professional background, PHPer is a halfway monk. Forgive me for my poor vocabulary. I really don’t know what the name of this form is. It doesn’t affect development and I’m too lazy to look it up.) At the end of the read function, 5.x returns false, and 7.x requires return '', resulting in the inability to write to the session.
I won’t go into details about the picture above. Those who often deduct code from projects should be able to see which one this is. Source code.
Be sure to read the article carefully. I spent half the night on this problem, and finally solved it by reading the first article Recommended study: "PHP video tutorial》
The above is the detailed content of What to do if the php7 session cannot be maintained. 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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

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

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.

SublimeText3 Chinese version
Chinese version, very easy to use