This article mainly introduces the php Solution for verifying invalid sessions, which involves the judgment and modification of the session cache directory. It is a common problem for session operations. For more information, see
This article mainly introduces the php Solution for verifying invalid sessions, which involves the judgment and modification of the session cache directory. It is a common problem for session operations. For more information, see
This article describes how to verify invalid session in php. Share it with you for your reference. The specific method is as follows:
I. Problems
It took a long time to configure the apache + php environment today. Later, it succeeded, but found that the verification code image can be generated. during login verification, it was found that the session was empty and there was no value.
Ii. Solution
Environment: apache + php
The program code is as follows:
The Code is as follows:
Process the post. php file after submission
The Code is as follows:
If ($ _ SESSION ['ssioner]! = $ Ssever ){
Echo ("script" alert ('verification code must consist of four digits! '); History. back (); script "); exit;
}
The result shows that the verification code must be composed of four digits and the output session is printed:
The Code is as follows:
Echo $ _ SESSION ['ssioner'];
Exit;
It was always blank, so I thought of a session file directory configured in the php environment. Now we find the php. ini configuration file
Upload_tmp_dir
This directory is found to be
Upload_tmp_dir = "D: \ tp"
I checked my d disk and found that there was only a file but no tp directory, so the problem was found. At that time, I created a tp directory and restarted apache and found that there was a sess_i40gl0p4hfep5r69j67o1k26d01 file in the tp directory, in this way, the logon is successful again.
I hope this article will help you with PHP programming.