Folks,
Look at this code. It gives no error:
//WORKING FINE
session_start();
echo session_id();
echo "<br>";
echo __LINE__;
echo "<br>";
if(!session_id() || !isset($_SESSION['form_step']) || $_SESSION['form_step'] != 'end')
{
echo __LINE__;
echo "<br>";
$_SESSION['form_step'] = 'start';
echo $_SESSION['form_step'];
echo "<br>";
echo session_id();
echo "<br>";
$_SESSION['form_step'] = 'end';
echo $_SESSION['form_step'];
echo "<br>";
echo __LINE__;
echo "<br>";
}
elseif($_SESSION['form_step'] == 'end')
{
echo __LINE__;
echo "<br>";
echo $_SESSION['form_step'];
echo "<br>";
echo session_id();
echo "<br>";
echo __LINE__;
echo "<br>";
}
And look at this one that gives error: Notice: Undefined index: form_step in C:\xampp\htdocs\power.page\pagination_test_SIMPLE.php on line 143
//WHY GIVES UNDEFINED ERROR ON LINE: elseif($_SESSION['form_step'] == 'end')
session_start();
echo session_id();
echo "<br>";
echo __LINE__;
echo "<br>";
if(!session_id())
{
if(!isset($_SESSION['form_step']) || $_SESSION['form_step'] != 'end')
{
echo __LINE__;
echo "<br>";
$_SESSION['form_step'] = 'start';
echo $_SESSION['form_step'];
echo "<br>";
echo session_id();
echo "<br>";
$_SESSION['form_step'] = 'end';
echo $_SESSION['form_step'];
echo "<br>";
echo __LINE__;
echo "<br>";
}
}
elseif($_SESSION['form_step'] == 'end')
{
echo __LINE__;
echo "<br>";
echo $_SESSION['form_step'];
echo "<br>";
echo session_id();
echo "<br>";
echo __LINE__;
echo "<br>";
}
die;
Both codes are practically the same. I just changed this line from the 1st code:
if(!session_id() || !isset($_SESSION['form_step']) || $_SESSION['form_step'] != 'end')
{
to this line in the 2nd code:
if(!session_id())
{
if(!isset($_SESSION['form_step']) || $_SESSION['form_step'] != 'end')
{
That is all. The 2nd code giving the error. Q1. How come the 1st code is not giving that same error ?