$_SESSION variable lost data

Silverstripe Version: 4.1

I add an inclue file in app/_config.php
Here I set $_SESSION[‘var’] variable. Then in PageController.php I define a login form.
After login Silverstripe lost $_SESSION[‘var’] value.
Any idea?

Details of your query go here

// Include any relevant code. If you have a lot of code, link to a gist instead.

There’s a Silverstripe\Control\Session component responsible for initialising and maintaining sessions for a Silverstripe app. Here’s more docs regarding how it works, but simply speaking, every session is usually attached to a HTTPRequest instance and may be preserved in a database (e.g. DynamoDB or MySQL) on the application level, so when you try to hijack it in the _config.php, it’s not initialized yet.