Home >Backend Development >PHP Problem >How to solve the problem of nginx php session failure

How to solve the problem of nginx php session failure

藏色散人
藏色散人Original
2021-10-19 10:56:142252browse

nginx PHP session failure solution: 1. Get the session directory; 2. Change the user group; 3. Set "session.use_trans_sid=1".

How to solve the problem of nginx php session failure

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

How to solve the problem of nginx php session failure?

Solution to the problem of cross-page session failure in nginx:

Get the session directory

Generally use session.save_path in php.ini Record the session in the storage directory of the server

session.save_path = "/var/lib/php/session"

Change the user group

chown -R nginx.nginx 'session.save_path'

Let’s take a look at the problem of disabling COOIKE in the browser:

session relies on cookies. When you visit When you visit a website, the server of this website will generate a unique session_id for you and store it in the client browser. When you jump to a page in the site, the browser will automatically send your unique session_id to the server, and the server will session_id gets session information. But when the browser disables cookies, your server cannot obtain the session_id, and the server cannot obtain your session information, which will cause the session to become invalid.

The solution is introduced below:

In this case, you can set session.use_trans_sid=1. When we send a request to the server, the URL will automatically transmit the value of session_id.

session.use_trans_sid=1

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to solve the problem of nginx php session failure. 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