November 20, 2017, 11:25pm
I’m getting a lot of warning in the logs like :
[-][-][warning][yii\web\Session::init] Session is already started
This happens for every $session = Yii::$app->session; at least that is the line number reported in the warning
I was trynig to detect active session libke this:
$session = Yii::$app->session;
but I’m still getting those warning, as those warning have quite a bit of troubleshooting information this logs grow quite big on a busy side.
What is the proper way of testing if session is already started?
November 21, 2017, 2:15am
$session->isActive is just wrapper around session_status(), could be a something small are you trying to start a session yourself else where in your application, may be check for possible session_start() function calls.
Also you don’t to need to start a session manually yii will start a session the moment the session component is initialized.
November 21, 2017, 9:15am
Are you saying I don’t need to run $session->open() at any point?
November 21, 2017, 10:06am
yes exactly you don’t need to open the session and fiddle with lower level api unless really necessary, just use the higher level api’s provided. here is an example
// to set a value
// or get a value
both set, get call open internally so you use that.