In Yii2, I am using database to store sessions.
I need to store some data in session but data is available only for the current request.
In ‘session’ table in mysql I can see a new entry each time a request comes.
So I concluded that the data lost is because a new session is created each time and old session is no more accessible.
I am clueless and need help in fixing this issue.
Details:
DBSession setting:
‘session’ => [
'class' => 'yii\web\DbSession',
// 'db' => 'mydb',
// 'sessionTable' => 'my_session',
],
Tried so far:
-
using session apis to get and set data as well as tried storing data directly in $_SESSION.
-
Opening session before storing data and reading data
-
Tried printing session id and observed with every request a new id is printed.
Screenshot of session table attached.