Summer vacation time to do a website, the former will move the site to the school's main server. Many web sites are deployed on this server and are accessed through the configuration of virtual hosts. Start to look normal, the page can be normal display, when I opened the background login page to log in, the strange phenomenon occurred: The verification code is always validation errors.
This site is done with a CMS template, the back and forth has been taken to do several sites, because this version of the CMS is older, there are some compatibility issues, so I would like to be due to the PHP version of the server is different caused it.
So I looked at the PHP code generated to generate verification codes, repeatedly check, is not found any problems, there is no compatibility issues. At this time I put my eyes on the session, did the site people know that the verification code is basically through the session to verify, generate a verification code when registering a global $_session variable, Then, when the user submits the form, the verification code is judged by checking whether the verification code entered by the user matches the global variable. I see the login page code is through the Session_register way to register the session, in the PHP5 this way has not been used, will not be the problem here. So I modified the way to register the SESSION, directly with the $_session[' variable name ']= ' XXX ' way to register. After modifying the code I was filled with joy to think that the problem should be done, refresh the page, sad a play, or pop up a "Captcha error." dialog box.
Then I went online to find information about the session, according to the operation of the Internet, or not. is struggling to open the php.ini file to see the configuration associated with the session, found that there is no configuration Session.save_path items, php.ini file can not be changed casually, I do not have permission, and search the Internet, found that the PHP page can be set to save the session itself, just need to use the Session_save_path () function before the session_start () function to configure. So in the login page to add this code, the session is set to save in the root of their own site in the next folder, modified to save and then refresh the page, the problem remains. And there is no session file found in that folder.
No way, continue Baidu bar. A post mentions phpinfo (), a function that basically sees all the configuration of the entire server. At that time also did not have much expectation, want to look at the server configuration, then added this function on the page, fortunately PHP.ini did not block this function, the server configuration smoothly displayed in front of me.
All the way down, find the session configuration that block, suddenly see session.save_path This configuration of the Local_value actually have value (a point to my site root directory of a folder path). I am surprised, the php.ini is clearly not configured, Ah, how can this come. A closer look, I found that the path is closed the root directory folder name does not match the actual folder name, that is, the path is a wrong, does not exist path. No wonder the session is always unable to verify that the original registration session variable after the save, in the match can not be obtained and can not match. But why do you have this path? I went online again, found that the original configuration of the virtual host can be configured session entries.
Think of here, solve the problem is very simple, find this server teacher, open httpd.conf file, find my web site of the virtual host configuration, a look, the session path presented in front of me. Quickly modify the path to the correct value and then restart Apache, open the site backstage, enter the account information, a smooth login.