3

im having a problem with a website iv been working on locally using easyphp server. I have now uploaded it to a webserver and where it was all working before, now I am getting php errors such as :

Call to undefined function session_status() in /home/site/public_html/index.php on line 2

Its only a simple script on the index page, but all of the other pages are suffering from the same session error problems, but it works locally which makes it even ore odd.

    <?php
    if (session_status() !== PHP_SESSION_ACTIVE) {session_start();}
    if (isset($_SESSION['key'])) {$sessionkey = $_SESSION['key'];}else {$sessionkey = '';}
    if ($sessionkey == 'sbhjbKA2bsbhjbKA209bhjbKA2bsbhjbKA209KaXff19u0bsbhjbKA209KaXff19u9Ka'){
         echo '<link rel="stylesheet" href="./css/template/template.css" />';
    include 'connectmysqli.php';
    include 'menu.php';

    }
    else
    {echo '<h1 style="font-family:Verdana, Geneva, sans-serif; color:red;">Access Denied !</h1>';}
    ?>
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
Iain Simpson
  • 8,011
  • 13
  • 47
  • 66

3 Answers3

10

session_status was introduced in PHP 5.4. Check your server's PHP version.

You could do without that call by the way, I'd say. Just always call session_start. If your code is riddled with it, just create a function stub.

Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195
3

Recommended way for versions of PHP >= 5.4.0

if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

For versions of PHP < 5.4.0

if(session_id() == '') {
    session_start();
}

source

Community
  • 1
  • 1
Elyor
  • 5,396
  • 8
  • 48
  • 76
1

it need PHP 5.4 ..

if you use xampp you can use this link check php vervion "phpinfo()"

Hiba
  • 101
  • 1
  • 2