Home >Backend Development >PHP Problem >What to do if session cookie is lost when php page jumps

What to do if session cookie is lost when php page jumps

coldplay.xixi
coldplay.xixiOriginal
2020-08-24 09:08:342579browse

Solution to the lost session cookie when jumping to the php page: Due to the limitations of the COOKIE sending mechanism, in files that already have BOM at the beginning of these files, the reason why COOKIE cannot be sent is to remove certain files. BOM, just upload it to the server again.

What to do if session cookie is lost when php page jumps

Solution to the lost session cookie when jumping to php page:

After searching for information, I found that it turned out to be a BOM header s reason. 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, the BOM problem occurs in the entry file. The way I deal with it is to use Notepad to open the file, and the format selection is UTF-8Encode without BOM format, then save and re-upload 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 the BOM, the problem of session cookie loss is solved.

Related learning recommendations: php programming (video)

The above is the detailed content of What to do if session cookie is lost when php page jumps. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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