Lose session if change tab in browser

My problem in my web is losing session if I change tab in browser.
example if a logged in user open page of my web in new tab on the same browser; he will log out
he has to log in again in the new tab but in old tab he will be login not log out.

What is the browser? Anonymous mode?

sorry for being late I was busy with the exams at university
all browsers; chrome; firefox; firefox developer; opera; brave …
the problem is if I copy the url from browser and past it in browser where i’m already log in I have to login again. if I copy link from a tab and past in another tab where i’m already log in I have to login again.

That’s very weird and definitely not normal. One thing to check is that session data is properly written. By default it’s trying to write to /tmp so check if files are there. Also, try directing your session to database to verify that the issue isn’t with file permissions.

Please can you tell me how to do that

https://www.yiiframework.com/doc/guide/2.0/en/runtime-sessions-cookies#custom-session-storage

I create two tables

  • one for session :

    CREATE TABLE session
    (
    id CHAR(40) NOT NULL PRIMARY KEY,
    expire INTEGER,
    data BLOB
    )

  • one for cache

    CREATE TABLE cache (
    id char(128) NOT NULL PRIMARY KEY,
    expire int(11),
    data BLOB
    );

and I add this lines to public_html/common/config/main.php

'components' => [
        'cache' => [
			'class' => 'yii\caching\DbCache',
        ],
		'session' => [
            'class' => 'yii\web\DbSession',
            // 'db' => 'mydb',  // the application component ID of the DB connection. Defaults to 'db'.
            // 'sessionTable' => 'my_session', // session table name. Defaults to 'session'.
        ],
    ],

.
I opened my web on chrome and login with my username and password and then I copied link of my web from Firefox and past it in chrome; But still I have to login again.