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 here is redundant. It is not needed.
– Mike
2 days ago


isset

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Possible Unhandled Promise Rejection (id: 0): ReferenceError: user is not defined ReferenceError: user is not defined

Opening a url is failing in Swift