Could not access session variable

Could not access session variable in a custom file in yii2.

I am trying to checking if admin area is logged in or not using session variable from Yii::$app->session[‘loggedAdminID’]; into a 3rd party file, but I could not access this session variable(FYI, $_SESSION also not accessible).

How can I access session variable? Please help.

you have to start a session before you call $_SESSION