out of the blue I was getting the following error when logging in to one of my sites:
Call to undefined function session_register()
After some research I saw that session_register() is deprecated after PHP 5.4. I checked in my hosting control panel, and sure enough it says current version I'm running is PHP 5.4.19. I assume they just forced an upgrade which is why this problem seemed to occur out of the blue.
I looked through several Stack Overflow posts and reviewed links to PHP documentation. From what I gather, session_register() is deprecated and should be replaced with $_SESSION instead.
Problem is, both of those already appear in my code. Here is the code in my index.php file:
53 <? if ($username) {
54 session_register("ADMIN");
55 $_SESSION['ADMIN'] = $username;
56 ?>
So I hoped just by removing line 54 (the deprecated piece) then it should work, however that is not the case. It broke the code when I did that.
Based on other posts I read HERE and HERE they seem to be saying that the code I see in line 55 above should by itself do the trick. So I'm a bit confused why it didn't work. If anyone can tell me what code I should use I would sincerely appreciate it. The developer of the script is not really offering support.
NOTE: Also, yes there is session_start() called at the very top of the page.
Because session_register('ADMIN')
registers the global variable with that name in the current session, so maybe in your code you have $ADMIN variable, find them and replace them with:
$_SESSION['ADMIN']
I hope this will help you.
Possible it is missing the call for session_start, session_register make this automatically, so what you have to do is just make sure that you have called session_start before use $_SESSION global.
You can check more here http://www.php.net/manual/en/function.session-register.php
If session_start() was not called before this function is called, an implicit call to session_start() with no parameters will be made. $_SESSION does not mimic this behavior and requires session_start() before use.
Looks like I overlooked the obvious. I was on the right track by simply removing the old session_register code.
But notice the original code I posted starts
<?
instead of
<?php
doh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With