Home > Backend Development > PHP7 > What to do if the php7 session cannot be maintained

What to do if the php7 session cannot be maintained

藏色散人
Release: 2023-02-18 09:38:02
Original
2484 people have browsed it

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.

What to do if the php7 session cannot be maintained

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 tutorialWhat to do if the php7 session cannot be maintained

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!

Related labels:
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