简体   繁体   English

无法使用Yii登录

[英]Can't login with Yii

I developed my site on my local server and had no problem, I then put it on a live server and had no problem, I have since moved it to a VPS but I'm having a strange thing happen in that I can't login any more. 我在本地服务器上开发了站点,没有问题,然后将其放置在活动服务器上,没有问题,此后将其移至VPS,但发生了一件奇怪的事情,因为我无法登录还有。 The new server has newer software like PHP 5.5 (but my localhost also had that). 新服务器具有更新的软件,例如PHP 5.5(但我的本地主机也有)。 I'm not really sure where to start with finding the problem. 我不太确定从哪里开始寻找问题。

my config looks like this: 我的配置看起来像这样:

'session' =>array(
        'savePath' => '../mySession',
        'sessionName' => 'my_session',
        'cookieParams' => array(
                 'secure' => true,
                ),
    ), 

I can see my sessions are being saved into the session folder. 我可以看到我的会话正在保存到会话文件夹中。 I am able to change the language of my site which uses a session too. 我也可以更改使用会话的网站的语言。 So I'm not entirely sure it is a session problem, or what it is, hence my question. 所以我不能完全确定这是一个会话问题,或者是什么问题,因此是我的问题。

Update 更新

I looked into the action and this is standard Yii code 我调查了操作,这是标准的Yii代码

if($model->validate() && $model->login())
            echo 'hello';//$this->redirect(Yii::app()->user->returnUrl); 
    }

When I ran this, the page echoed out Hello and I could see I was logged in. When I went to click my profile, it then loaded the login page again and showed I was logged out. 运行此命令时,该页面回显了Hello ,我可以看到我已登录。当我单击我的个人资料时,它再次加载了登录页面并显示我已注销。 So It seems to be a session retention issue? 因此,这似乎是会话保留问题?

The only thing I can see that is strange is that In my local host I can see my_session and the yii_csrf session. 我唯一看到的奇怪的是,在我的本地主机中,我可以看到my_session和yii_csrf会话。 But on my VPS I can see these two and also a PHPSESSION, so I'm wondering if that is causing the conflict, but I don't know. 但是在我的VPS上,我可以看到这两个以及一个PHPSESSION,所以我想知道这是否引起了冲突,但我不知道。

我想我已经解决了这个问题,尽管为我运行phpinfo()的savePath设置了配置文件,它显示了我的本地值作为会话保存路径,但是我的主值仍然是tmp目录。

You can try the following code and check if the session component is preloaded (in your configuration file). 您可以尝试以下代码,并检查会话组件是否已预加载(在配置文件中)。 Maybe the session hasn't started. 会话可能尚未开始。 Finaly make sure your session folder is writeable. 最后,请确保您的会话文件夹可写。

 'session'=>array(
                    'timeout'=>3600,
                    'sessionName'=>'my_session',
                    'autoStart'=>true,
                    'class'=>'CHttpSession',
                    'cookieMode'=>'only',
                    'cookieParams' => array(
                        'secure' => true,
                    ),
                ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM