Mohamed Said
Mohamed Said

Reputation: 4613

Checking a session variable in a PHP class

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?

Upvotes: 1

Views: 896

Answers (1)

maček
maček

Reputation: 77778

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

PHP session_start() docs

Upvotes: 1

Related Questions