Link to home
Start Free TrialLog in
Avatar of Computer Guy
Computer Guy

asked on

Fatal error: Call to undefined function session_is_registered() in

Hi,

I know the cause of this issue. I have PHP 5.4 on a new host and this error is due to that since it was older on another host.

Is there something I can edit in a custom php.ini file to make this go away and still keep using it?

Thanks!
Avatar of Gary
Gary
Flag of Ireland image

You can't use it, it's been removed.

Now you have to check if it is set

if(isset($_SESSION['session_name'])){
...
ASKER CERTIFIED SOLUTION
Avatar of Brian Tao
Brian Tao
Flag of Taiwan, Province of China image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please see the second foreword to this article:
https://www.experts-exchange.com/Programming/Languages/Scripting/PHP/A_2391-PHP-login-logout-and-easy-access-control.html

Executive summary: This was deprecated at PHP 5.3, over 5 years ago.  There are other, current PHP functions that do things the right way, so just correct the code.  Here's one suggestion:
http://php.net/manual/en/function.session-is-registered.php#111878
Avatar of Computer Guy
Computer Guy

ASKER

This is what the original code is:
      if (session_is_registered($k))        continue;

Is this the correct syntax to replace it with?
      if (!function_exists('session_is_registered($k'))continue;{
  function session_is_registered($k){
    return (isset($_SESSION[$k]));
Umm, probably this is a correct replacement.
if (isset($_SESSION[$k])) continue;

Open in new window

If you want to explore the deep-background thinking on the session-register concept and why it's not used any more, learn about register-globals.  Automatic injection of external variables was supposed to make PHP "easy" but it actually made PHP horribly insecure and hackable, so we don't do that any more.

If you look at your code base and find a lot of instances of session_is_registered() then it might make sense to define the function, but my thinking would be to just correct the code, since the correction using isset() will be forward and backward compatible.