I am working in a subfolder on my website: www.example.com/subfolder
Now, i want to set a session that is only accessible within www.example.com/subfolder
To
_SESSION is superglobal. It is in global scope.
So, you have probably forgot session_start();
Have you used session_start() anywhere before that code ?
I also suggest using var_dump()
instead of print_r()
to debug values as print_r doesn't output null values, hence creating some confusion sometimes.
You need to call session_start
first (unless you have session.auto_start set to 1).