Reputation: 1674
So the problem is what the title says. The frontend
session is reset on every page refresh. The backend
one works fine. My config looks like ( frontend ):
'session' => [
// this is the name of the session cookie used for login on the frontend
'name' => '_frontendSessionId',
'savePath' => __DIR__ . '/../runtime/sessions'
],
No file is created in __DIR__ . '/../runtime/sessions
folder. Also there is no _frontendSessionId
in the browsers cookies. What can cause this? Thank you!
Upvotes: 2
Views: 681
Reputation: 1105
1- Please edit savePath:
'savePath' => dirname(__DIR__) .'/frontend/runtime/sessions'; //Or whatever you prefer
2- Please make sure the session is active when you open the frontend page. (Login or ....)
$session = \Yii::$app->session;
$session->open();
Good luck.
Upvotes: 1
Reputation: 282
I have your problem finally I use this code in every page I need session
$_SESSION['referrer_page']=Yii::$app->request->referrer;
Upvotes: 1