bobbyjones bobbyjones - 1 year ago 152
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download