Solved

Fatal error: Call to undefined function session_is_registered() in

Posted on 2014-10-03
6
180 Views
Last Modified: 2014-10-16
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!
0
Comment
Question by:Computer Guy
6 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40359831
You can't use it, it's been removed.

Now you have to check if it is set

if(isset($_SESSION['session_name'])){
...
0
 
LVL 9

Accepted Solution

by:
Brian Tao earned 500 total points
ID: 40359924
I haven't tried it but I think you can add the following code to your script so that it runs on both old and new PHP versions:
if (!function_exists('session_is_registered')){
  function session_is_registered($sess_name){
    return (isset($_SESSION[$sess_name]));
  }
}

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40360143
Please see the second foreword to this article:
http://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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Author Comment

by:Computer Guy
ID: 40360815
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]));
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40360825
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.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40384120
To amyone coming upon this Q/A in the future, the explanation of the issue can be found here:
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28530812.html#a40360143

And the correct answer (at least the one that won't get you fired) is here:
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28530812.html#a40360825
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now