'm attempting to run a Craft app alongside a Yii2 application currently. I’ve got the correct app bootstrapping at the correct time but am running into a session writing issue.
I’m writing the sessions into a local file (default apache2 file).
For some reason when I attempt to add a variable to the session using $_SESSION[‘something’] = ‘test’; in my Yii2 app it becomes unavailable the minute the app shuts down.
I’m adding this ‘something’ key to the session in Yii2 and attempt to access the session variable in my Craft app about 3 seconds later.
Any ideas why this session variable is getting lost? If I print out the $_SESSION before I return from my Yii2 app it’s there but then it gets lost from the session after my action finishes executing?
The way my controller finishes executing is this:
//Setup for the return of JSON.
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
header('Content-type: application/json');
$returnData = self::filterOutSensitiveResponseInfo($returnData);
//Get timeouts for the front-end.
$returnData = [
"responseData" => $returnData
];
//Handle logging of the return from controller.
if(self::includeCurrentActionInLogs()){
self::logActionTiming();
self::logActionResponse($returnData);
}
//output JSON to the front-end.
echo json_encode($returnData, JSON_PRETTY_PRINT);
//Handle successful shutdown of the application.
\Yii::$app->end();
return;
Once this code is done executing I’m immediately calling another controller action and looking at $_SESSION but that variable I stored previously is no longer there?