在注销和登录时保留会话 [英] Preserve Session on Logout and Login

查看:54
本文介绍了在注销和登录时保留会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我像这样打印出会话 ID:

I print out the session ID like this:

<?php print YII::app()->session->sessionID; ?>

当我登录并检查我的ID时,它类似于:huh09vuo33scdlkmfuc8651t12,例如.如果我注销并再次检查,我的 ID 保持不变.但是,如果我再重新登录,会话 ID 就会改变!

When I log-in and check my ID, it is something like: huh09vuo33scdlkmfuc8651t12, for example. If I log out and check again, my ID remains the same. However, if I then log back in again, the session ID changes!

我的问题是我的会话中有信息需要存储在 cookie 中并在登录后重新加载.如果会话 ID 发生变化,我如何唯一确定登录的用户是正确的用户?

My problem is that I have information in my session that I need to store in a cookie and reload after login. How can I uniquely establish that the user logged in is the correct user if his session ID changes?

推荐答案

不要问我如何,但这解决了我的问题:

Dont ask me how, but this fixed my problem:

我改变了:

Yii::app()->user->logout();

Yii::app()->user->logout(false);

也许它会帮助其他人,或者至少引导他们朝着正确的方向前进.

Maybe it will help someone else, or at least steer them in the right direction.

这篇关于在注销和登录时保留会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆