Changing cookies as documented causes error

I added litteraly the official documented code [see http://www.yiiframework.com/doc-2.0/guide-tutorial-shared-hosting.html#separate-sessions-and-cookies] to my backend config to avoid error having backend and frontend under the same domain. Precisely, my backend respond to ‘/backend’




'user' => [

            'identityCookie' => [

                'name' => '_backendIdentity',

                'path' => '/backend',

                'httpOnly' => true,

            ],

        ],



When I load localhost/backend I got

How to solve?

Did you accidentally delete ‘identityClass’ property from ‘user’ configuration when added ‘identityCookie’?

Or added a duplicate ‘user’ key to ‘components’ array and the second one overrides the first?

None of them, I started with default main.php file for backend config, and added what I’ve seen in the linked guide.

Must I add some others? What class name must I use?

I falsely assumed that you started with advanced application template which contains an implementation of IdentityInterface and the necessary configuration. Seems like you have to implement it yourself. When done, add it to the configuration:




'user' => [

  'identityClass' => '@path/to/your/class',

  // ...

],



No, you were right. I started with advanced template, then I’m trying to allow coexistence of frontend and backend on the same domain.

so I followed the official guide, I added the posted code and the backend doesn’t work as explained.

But I’ve no modified nothing else