Yii2 Error: cookieValidationKey Must be Configured With a Secret Key

After I ran composer update to get new Yii2 framework version, I got this error

yii\web\Request::cookieValidationKey must be configured with a secret key

To overcome this error, I added this code below in config/main.php

'components' => [
        'request' => [
            'enableCookieValidation' => true,
            'cookieValidationKey' => 'your-validation-key',
        ],
......

Hope it helps.

  • Richard Buchanan

    It would have been nice if you showed me exactly where to put this?

    • deerawan

      I have mentioned it in article. :) it is on config/main.php

  • gracias!

  • Luis Pintado

    Can you publish a new version of Restful Api with this new yii2 update? I have seen the new file structure is pretty different

  • Stéphane Winnepenninckx

    I’m new to Yii 2.0.6 (basic) and I do not have a config/main.php

  • Raul Islas

    Cuál es o dónde consigo el “validation-key”

  • Jaydeep Magneto IT Solutions

    Its really helpful to me. Thanks

  • vb vicky

    realy helpfull to me.thank u so much