简体   繁体   English

yii framework:无法登录到gii

[英]yii framework: cannot login to gii

I just following the yii-blog.pdf from the documentation, when I tried to login to gii, it keep showing me the login form all the time. 我只是按照文档中的yii-blog.pdf进行操作,当我尝试登录到gii时,它一直在向我显示登录表单。

I create a virtual host for this like http://yii.blog and then tried to access from http://yii.blog/index.php?r=gii 我为此创建了一个虚拟主机,例如http://yii.blog ,然后尝试从http://yii.blog/index.php?r=gii访问

in the config/main.php 在config / main.php中

'modules'=>array(
    // uncomment the following to enable the Gii tool
    'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'12345',
                //'ipFilters'=>array('127.0.0.1','yii.blog')
    ),
),

when I type the wrong password the form could say "Incorrect password." 当我输入错误的密码时,表单可能会显示“密码错误”。 but when I type the correct one, it didn't say any error and it keep showing me the login form. 但是当我输入正确的密码时,它没有显示任何错误,并且一直显示登录表单。

I am using YII 1.1.5 我正在使用YII 1.1.5

Any idea how to solve this? 任何想法如何解决这个问题?

Logging into Gii requires the use of PHP server sessions, so testing in another browser or clearing cache and cookies helps rule out issues on the browser end wich may interfere with session handling. 登录Gii需要使用PHP服务器会话,因此在其他浏览器中进行测试或清除缓存和cookie有助于排除浏览器端可能会干扰会话处理的问题。 However, if that fails, you may need to check your PHP configuration: 但是,如果失败,则可能需要检查PHP配置:

  • Use command line statement php -i |grep session.save 使用命令行语句php -i |grep session.save
  • Save a file containing <?php phpinfo(); ?> 保存一个包含<?php phpinfo(); ?>的文件<?php phpinfo(); ?> <?php phpinfo(); ?> on your server and view it in your browser, then do an in-page search for "session.save" <?php phpinfo(); ?>在您的服务器上并在浏览器中查看它,然后在页面内搜索“ session.save”

In my case it turned out to be a misconfiguration in my PHP.ini: the default session path wasn't configured. 在我的情况下,结果证明我的PHP.ini中配置错误:未配置默认会话路径。 I edited the config file for my server and set a valid path for session.save_path . 我为服务器编辑了配置文件,并为session.save_path设置了有效路径。 I uncommented the relevant line in my default PHP.ini and I was able to login to Gii with the valid password after including the following two lines--though other session configurations are possible. 我在默认的PHP.ini中取消了对相关行的注释,并且在包含以下两行之后,我可以使用有效的密码登录Gii了-尽管可以进行其他会话配置。

session.save_handler = files
session.save_path = "/tmp"

I have had issues with Chrome with this, restarting Chrome worked for me. 我在使用Chrome时遇到了问题,重新启动Chrome可以为我工作。 Firefox had no problems at all. Firefox完全没有问题。

None of the answers worked for me. 没有答案对我有用。 I removed the password all together. 我一起删除了密码。

    'configWeb' => array(
    // Modules
     'modules' => array(
        'gii' => array(
            'class' => 'system.gii.GiiModule',
            'password' => false,
        ),
    ), 

We're using multiple config files for different environments like development, staging, and production. 我们正在针对不同环境(例如开发,登台和生产)使用多个配置文件。 When I had problems, I was probably editing the wrong file anyways. 当我遇到问题时,我可能还是在编辑错误的文件。

Sounds like a session/cookie issue. 听起来像是会话/ Cookie问题。 Try restarting the browser like Don mentioned, or using a different browser. 尝试重新启动浏览器(如Don提到的那样),或使用其他浏览器。 Also a cache-clearing refresh (Ctrl+F5) might do the trick. 同样,清除缓存刷新(Ctrl + F5)也可以解决问题。

I also had to set up URL aliases to make Gii work, since I am using URL rewrite rules, like so: 我还必须设置URL别名才能使Gii正常工作,因为我正在使用URL重写规则,如下所示:

'components'=>array(
  'urlManager'=>array(
    'rules'=>array(
      'gii'=>'gii',
      'gii/<controller:[\w\-]+>'=>'gii/<controller>',
      'gii/<controller:[\w\-]+>/<action:\w+>'=>'gii/<controller>/<action>',
    )
  )
)

Try this if you using the urlManager (which it actually looks like you are not). 如果您使用urlManager(实际上看起来好像不是),请尝试此操作。

删除浏览器的域Cookie对我来说已解决了该问题

Check in your php.ini as to what dir you have set for session.save_path, 在php.ini中检查您为session.save_path设置的目录,

php -i | grep session.save_path

and then make sure that folder is writable by your web user/group. 然后确保该文件夹可被您的Web用户/组写入。

example: 例:

sudo chgrp www-data /opt/lampp/temp/

Clean cookies, or more specific all PHPSESSID's. 清除cookie,或更确切地说是所有PHPSESSID。 Sometimes it clutters withdomains of upper level. 有时,它会杂乱上层域。

I have the same problem (in 'Yii Example App' login work successfuly but Gii not and without any error message). 我有同样的问题(在“ Yii示例应用程序”中登录成功,但是Gii没有并且没有任何错误消息)。 after hours I solve problem by changing php.ini of my Denwer server: 下班后,我通过更改我的Denwer服务器的php.ini解决了问题:

session.save_path = "/tmp"

by 通过

session.save_path = "d:\tmp"

PS I hope this helps someone. PS我希望这可以帮助某人。

My problem was my session component where I had set cookieMode to none : 我的问题是我的session组件,其中我已将cookieMode设置为none

'components'=>array(
    /* ... */
    'session' => array (
        'autoStart' => false,
        'cookieMode' => 'none', /* This means gii cannot set cookies! */
    ),
    /* ... */
);

Here cookieMode should be set to only instead: 在这里, cookieMode应该设置为only

'components'=>array(
    /* ... */
    'session' => array (
        'autoStart' => false,
        'cookieMode' => 'only', /* "only" will allow gii to set cookies */
    ),
    /* ... */
);

You can write any password you want to the config file – look for it here: /protected/config/main.php, the section you need will look 您可以将任何密码写入配置文件–在此处查找:/protected/config/main.php,您需要的部分将在

'modules'=>array(
    // uncomment the following to enable the Gii tool

    'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'generatorPaths'=>array('bootstrap.gii'),
        'password'=>'yourPassword',
    ),
)

One year after ..... I had this error too. 一年后...我也有这个错误。 In my case I had two versions of PHP. 就我而言,我有两个版本的PHP。 First I installed Wamp 2.0i with PHP 5.3.0. 首先,我使用PHP 5.3.0安装了Wamp 2.0i。 With this PHP version I installed yii 1.1.8 and started some test projects. 使用此PHP版本,我安装了yii 1.1.8并启动了一些测试项目。

After that I copied the folder 5.2.5 of PHP from another WAMP installation in another machine. 之后,我从另一台计算机上的另一个WAMP安装中复制了PHP的5.2.5文件夹。 when I select PHP 5.2.5 in the WAMP tray menu selector I cann't connect to gii exactly as nightingale2k1 said. 当我在WAMP托盘菜单选择器中选择PHP 5.2.5时,我无法完全按照nightingale2k1的说明连接到gii。

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

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