Jump to content

$_SESSION['logged_in']


sepoto

Recommended Posts

I keep getting errors in regards to this variable. Like this one:Notice: Undefined index: logged_in in /var/www/htmlincs/main_nav.inc on line 11Anyone know what may be happening?

Link to comment
Share on other sites

that usually means an index you're looking for in an array or an object's member/property doesn't exist. what's the code in question?

Link to comment
Share on other sites

PHP will automatically create a new session if the HTTP request doesn't contain an existing session ID... this in turns means that any session variable you have may not be defined.Simply put, you should test if this "logged_in" index exists, and only proceed if it does. You can do that with isset(), like:

session_start();if (isset($_SESSION['logged_in'])) {//You're not going to see this error anymore}else {//New session created, variable doesn't exist.//If this is unexpected, take according actions like redirecting to the login form for example}

I assume you're calling session_start() correctly, right? You should indeed show the code in question, just in case.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...