Lose session if change tab in browser

(Byndstd) #1

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.

(Alexander Makarov) #2

What is the browser? Anonymous mode?

(Byndstd) #3

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.

(Alexander Makarov) #4

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.

(Byndstd) #5

Please can you tell me how to do that

(tri - Tommy Riboe) #6


(Byndstd) #8

I create two tables

  • one for session :

    CREATE TABLE session
    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.