bobbyjones bobbyjones - 1 month ago 10x
PHP Question

Notice: Undefined index: session PHP

This error only shows if user is not logged-in. I understand there are already a couple of errors like this, ive tried my best to test them all. but i still cant figure this out.

Notice: Undefined index: user_session in ..index.php on line 10


if (session_status() == PHP_SESSION_NONE){
header('Location: index.php');

if (session_status() == PHP_SESSION_ACTIVE) {
$session = $_SESSION['user_session']; //line 10


When user logs in , you have to set this $_SESSION["user_session"]=$value; first then only you will be able to access it. You are trying to access a variable which you haven't set anywhere. So its throwing undefined index.