-1

it is saying this session_status is undefined function . can you tell me whats the replacement of it. in the given code

   <?php

in this line it gives error.. plz give me the replacement of this code

    if (session_status() != PHP_SESSION_NONE) {
    session_destroy();
    }
    session_start();
    if(!isset($_POST['secure'])){
     $_SESSION['secure']=  rand(1000, 2000);
     }
    else
    {
     if($_SESSION['secure']==$_POST['secure'])
     {


     }
     else
     {
      echo 'incorrect , try again';
    $_SESSION['secure']=  rand(1000, 2000);
}
}

 ?>

plz help me i am stucked here

komal deep singh chahal
  • 1,229
  • 3
  • 13
  • 28

2 Answers2

2

Well as you can see on http://php.net/manual/en/function.session-status.php the function was introduces in 5.4 so there is no hope in getting it in 5.3. You can see in the comments that you can use return session_id() === '' ? FALSE : TRUE; as a sort off replacement, but it is not 100% correct.

Tell your host to update to php 5.4 the 5.3 is EOL since 14 Aug 2014.

mcq8
  • 249
  • 1
  • 5
1
if (isset($_SESSION)) {
    //do something
} else {
    //do other stuff
}
al'ein
  • 1,711
  • 1
  • 14
  • 21
  • like didnt get you.. how – komal deep singh chahal Aug 17 '15 at 17:12
  • `session_start()` sets the `$_SESSION` superglobal. If you didn't start any session with `session_start()`, `$_SESSION` won't be set. By verifying this you should know if there's a session running and you can destroy or use it. – al'ein Aug 17 '15 at 17:15