search

Home  >  Q&A  >  body text

php - yii2 generates two sessions after logging in, chrome browser

Yii2 framework, after automatic login is turned off, when logging in with browsers such as Chrome browser, domestic 360, and QQ browser, two sessions will be generated, one is the precise domain name of this website, and the other is the vague second-level domain name . If multiple websites use the same second-level domain name, one website will be forcibly kicked down when switching back and forth. Because there is one more session. Waiting online for rescue by the great god

阿神阿神2782 days ago538

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-16 13:01:33

    Post your session configuration

    In the config/main.php of your project,

    return [
        ...
        'components' => [
            ...
            'session' => [
                'class' => 'yii\web\Session',
                'cookieParams' => [
                    'domain' => 'backend.mysite.com', // 这里固定你的session域名
                    'lifetime' => 3600 * 24 * 30,
                ],
                'name' => 'PHPSESSID_FOR_BACKEND', // 最好是不同的域名也设置不同的name
            ],
            ...
        ],
        ...
    ];

    reply
    0
  • Cancelreply