Solution to the problem of user login session loss in Yii framework

高洛峰
Release: 2023-03-05 13:40:01
Original
1399 people have browsed it

The example of this article describes the solution to the problem of user login session loss in Yii framework. I would like to share it with you for your reference. The details are as follows:

I recently worked on a project and used the YII framework. When users log in, sometimes they can log in and sometimes they cannot. After debugging it many times, I thought it was a server configuration problem at first. However, no matter how I tested it, it still failed to work. Sometimes the login session was still lost. I had no choice but to ask in the group, post, and ask experts for advice. In the end, no problem was found.

I accidentally saw someone on the Internet talking about the problem of yii session loss. Finally solved, solution:

Initial solution:

Open the file yii\framework\web\auth\CWebUser.php #700 or so, comment out the following statement

Yii::app()->getSession()->regenerateID(true);
Copy after login

He calls PHP’s built-in function by default:

bool session_regenerate_id ( [bool delete_old_session] )
Copy after login

There is no problem for the time being. It still needs to be observed for some time.

I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.

For more articles related to solutions to the Yii framework user login session loss problem, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!