简体   繁体   中英

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.

I create a virtual host for this like http://yii.blog and then tried to access from http://yii.blog/index.php?r=gii

in the 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

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. However, if that fails, you may need to check your PHP configuration:

  • Use command line statement php -i |grep session.save
  • Save a file containing <?php phpinfo(); ?> <?php phpinfo(); ?> on your server and view it in your browser, then do an in-page search for "session.save"

In my case it turned out to be a misconfiguration in my PHP.ini: the default session path wasn't configured. I edited the config file for my server and set a valid path for 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.

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

I have had issues with Chrome with this, restarting Chrome worked for me. Firefox had no problems at all.

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. Try restarting the browser like Don mentioned, or using a different browser. Also a cache-clearing refresh (Ctrl+F5) might do the trick.

I also had to set up URL aliases to make Gii work, since I am using URL rewrite rules, like so:

'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).

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

Check in your php.ini as to what dir you have set for session.save_path,

php -i | grep session.save_path

and then make sure that folder is writable by your web user/group.

example:

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

Clean cookies, or more specific all PHPSESSID's. 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). after hours I solve problem by changing php.ini of my Denwer server:

session.save_path = "/tmp"

by

session.save_path = "d:\tmp"

PS I hope this helps someone.

My problem was my session component where I had set cookieMode to none :

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

Here cookieMode should be set to only instead:

'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

'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. First I installed Wamp 2.0i with PHP 5.3.0. With this PHP version I installed yii 1.1.8 and started some test projects.

After that I copied the folder 5.2.5 of PHP from another WAMP installation in another machine. when I select PHP 5.2.5 in the WAMP tray menu selector I cann't connect to gii exactly as nightingale2k1 said.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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