I'm facing a bit of a hurdle with PHP session variables, and I was hoping someone here could help me out. I'm currently working on a project where I need to access a session variable, but the variable name is stored as a string.
For example, let's say I have a session variable called "username", but I want to access it using the variable name stored in another variable, let's say "$var". So essentially, I want to do something like $_SESSION["$var"], where $var contains the string "username".
I've been searching for a solution but haven't been able to find anything helpful so far. Is there a way to achieve this in PHP? Any suggestions or examples would be greatly appreciated.
Thanks in advance!