Solution to the problem of unable to log in due to loss of session cookie in PHP page jump

巴扎黑
Release: 2023-03-03 22:22:01
Original
2011 people have browsed it

A project developed by thinkphp. After successful login, it jumps to the login page. After submitting the information, the session output is normal and there is no problem. However, after the page jumps, the session is lost and the login cannot be completed normally.

After searching for information, I found out that it was the cause of the bom. Due to the limitations of the COOKIE sending mechanism, in files that already have a BOM at the beginning of these files, the COOKIE cannot be sent (because PHP has already sent the file header before the COOKIE is sent), so the login and logout functions are invalid. All functions that rely on COOKIE and SESSION are invalid.

The correct way to deal with it is to remove the BOM of some files. Generally, it is a BOM problem that occurs in the entry file. The way I deal with it is to open the file with Notepad++, select the format to encode in UTF-8 BOM-free format, then save and re- Just upload it to the server. But be sure to note that before removing the BOM and uploading it to the server, you need to delete the source files on the server. Uploading overwrite cannot remove the BOM.

After removing BOM, the problem of session cookie loss is solved.


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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!