Solved

Fatal error: Call to undefined function session_is_registered() in

Posted on 2014-10-03
6
164 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …

758 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

18 Experts available now in Live!

Get 1:1 Help Now