Php solution for verifying invalid session

Source: Internet
Author: User
This article mainly introduces the php solution for verifying invalid sessions, which involves the judgment and modification of the session cache directory, which is a common problem for session operations, for more information about how to verify the invalid session in php, see the example in this article. 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: \ www.bitsCN.com \ tp"
I checked my D disk and found that there were only www.bitsCN.com files but no tp Directory. in this case, I found the problem. at that time, I created a tp directory, restart apache and you will find the sess_i40gl0p4hfep5r69j67o1k26d01 file in the tp Directory. then, you can log on again.

I hope this article will help you with PHP programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.