Fatal error: Call to undefined function session_is_registered()

I upgraded the PHP version of one of my old applications. The application was not working as expected. Here is the first error I’ve received.

Fatal error: Call to undefined function session_is_registered()

28-1406550233-alanganallur

session_is_registered() has been removed in PHP 5.5. We may need to use $_SESSION(‘username’).

I replaced the old code with the following.

if(!(isset($_SESSION(‘myusername’))))

Now it ended up with the following error! (AGAIN!)

Fatal error: Cannot use isset() on the result of a function call (you can use “null !== func()” instead)

Then I replaced it like this.

$myusername=$_SESSION(‘_user’);
if(null == $myusername)

Now,

Fatal error: Function name must be a string

And finally, this one worked.

if (!isset($_SESSION[“_user”]))

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top