Checking a session variable in a PHP class

2020-04-26 06:01发布

问题:

At the top of my index page a set a session using:

$_SESSION['language'] = 'english';

and when I echo $_SESSION['language'] it echoes 'english', However the session value is not readable inside a PHP class, why is that?

回答1:

You must call session_start() before you have access to the $_SESSION super global

PHP session_start() docs



标签: php oop session