当在函数中设置变量时,如何使SESSION变量起作用? 显示索引未设置

The issue i have is that within my login system of a database, i create session variables within a function so that they can be used in another file however they do not seem to be accessible outside of that files function meaning when i try to call the session variable in the other file it gives me a index not set error.

so far ive tried globalising the variables although im not sure how else to go about this issue any help would be appreciated.

session variables set

session variables being used