L
L
lolka022021-07-05 08:13:39
Yii
lolka02, 2021-07-05 08:13:39

Why does general authentication not work in ajax requests in Yii2?

I did a general authentication as written here https://klisl.com/yii2-aut-front-back.html . It seems to work correctly, but when you send a request from the front to the back url Yii::$app->user->isGuest returns true , although in fact it is authorized

In the httpOnly settings I made it false, but still something does not work

In backend and frontend configs

'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => [
                'name' => '_identity-common',
                'httpOnly' => false,
                'domain' => $params['cookieDomain']
            ],
            'loginUrl' => ['/'],
        ],
        'session' => [
            'name' => 'advanced-common',
            'cookieParams' =>[
                'httpOnly' => false,
                'domain' => $params['cookieDomain'],
            ]
        ],

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question