?
Solved

Fatal error: Call to undefined function session_is_registered() in

Posted on 2014-10-03
6
Medium Priority
?
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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 111

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
WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

 
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 111

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 111

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

752 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