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!
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!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
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_regist ered($k')) continue;{
function session_is_registered($k){
return (isset($_SESSION[$k]));
if (session_is_registered($k)
Is this the correct syntax to replace it with?
if (!function_exists('session
function session_is_registered($k){
return (isset($_SESSION[$k]));
Umm, probably this is a correct replacement.
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.
if (isset($_SESSION[$k])) continue;
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.
To amyone coming upon this Q/A in the future, the explanation of the issue can be found here:
https://www.experts-exchange.com/questions/28530812/Fatal-error-Call-to-undefined-function-session-is-registered-in.html?anchorAnswerId=40360143#a40360143
And the correct answer (at least the one that won't get you fired) is here:
https://www.experts-exchange.com/questions/28530812/Fatal-error-Call-to-undefined-function-session-is-registered-in.html?anchorAnswerId=40360825#a40360825
https://www.experts-exchange.com/questions/28530812/Fatal-error-Call-to-undefined-function-session-is-registered-in.html?anchorAnswerId=40360143#a40360143
And the correct answer (at least the one that won't get you fired) is here:
https://www.experts-exchange.com/questions/28530812/Fatal-error-Call-to-undefined-function-session-is-registered-in.html?anchorAnswerId=40360825#a40360825
Now you have to check if it is set
if(isset($_SESSION['sessio
...