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”]))

Advertisements

Fatal error: Call to undefined function session_register() in

This is related to my previous post about session_is_registered(). This post is about another deprecated function session_register(). Lets replace it by $_SESSION

Old format:

session_register("myusername");

New format:

$_SESSION['myusername']=$myusername;

Another Buddha!

Treasures from Asia’s Oldest Museum: Buddhist Art from the Indian Museum, Kolkata

Treasures from Asia’s Oldest Museum: Buddhist Art from the Indian Museum, Kolkata

Fatal error: Call to undefined function session_is_registered() in …

This is another nasty error when we access session attributes without proper check!

Fatal error: Call to undefined function session_is_registered() in G:\XAMPP\htdocs\market\login.php on line 2

This is a deprecated function. It will be resolved when we change to something like this.

if (!isset($_SESSION['myusername'])){

Treasures from Asia’s Oldest Museum: Buddhist Art from the Indian Museum, Kolkata

Treasures from Asia’s Oldest Museum: Buddhist Art from the Indian Museum, Kolkata