Unknow index of session [duplicate]
Unknow index of session [duplicate]
This question already has an answer here:
Ok guys when I try to run my simple php code I get this error: Notice: Undefined index: Status, here is my code:
<?php
session_start();
?>
<!DOCTYPE HTML>
<html>
<head>
--->All links
</head>
<body>
<?php
if($_SESSION['Status']=='1'){
?>
...--->NAV1
?>
<?php
}else{
?>
...NAV2--->
<?php
}
?>
</nav>
</body>
The error is on " if($_SESSION['Status']=='1'){
", this code will check if user is logged or not then shows a proper navbar.
if($_SESSION['Status']=='1'){
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1 Answer
1
Update your line.
if($_SESSION['Status']=='1'){
to
if(isset($_SESSION['Status'])
&& !empty($_SESSION['Status'])
&& $_SESSION['Status']=='1'){
isset
isset
here is redundant. It is not needed.– Mike
2 days ago