Home >Backend Development >PHP Problem >What to do if php session fails

What to do if php session fails

藏色散人
藏色散人Original
2021-09-12 10:10:413638browse

Solution to invalid php session: 1. Modify the address of "session_save_path"; 2. Find the temp folder on the computer and modify the permissions; 3. Restart IIS to make the modification effective.

What to do if php session fails

The operating environment of this article: Windows 2008 system, PHP version 7.1, DELL G3 computer

What should I do if the php session fails?

Solution to session unavailability in php

## Recently, because I have just come into contact with PHP, the code previously tested on the cloud server needs to be moved to the new server (version Windows 2008 server). The PHP version is 5.5.12. It turns out that the session function in the original PHP code is not available. Later, I checked online that it was due to a problem with the session storage directory in the PHP configuration file on the server. After some tossing, I roughly summarized the entire problem. The following instructions

take Windows 2008 server as an example.

1. Modify the address of session_save_path

session_save_path is the directory where session files are stored. If the directory is invalid or the file does not have write permission, the session will be unavailable.

Then first open the installation address of php in the server and open the php.ini configuration file. Then use ctrl F to search where session_save_path is found. First check whether the subsequent storage directory is a valid directory path. If it is invalid, change it to a valid folder directory. You can create a new directory and create the folder in the actual disk. The path I modified myself is the directory of c:/Windows/Temp.

What to do if php session fails

2. Modify permissions

The storage directory that has been created or modified in the previous step is not feasible if the folder does not have write permissions. . Then we still need to modify the permissions.

Find the folder on your computer, right-click Properties-Security-select Users-Edit-check the write permission.

What to do if php session fails

What to do if php session fails

What to do if php session fails##3. Restart IIS to make the changes take effect

Open IIS in the server (you can't find this anywhere, you can search online), and restart IIS.

At this point, the setting of session_save_path is complete. Hurry up and try the session function again to see if it works. Hope it helps everyone.

Recommended learning: "

PHP Video Tutorial

"

The above is the detailed content of What to do if php session fails. 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