sepoto Posted December 18, 2010 Share Posted December 18, 2010 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 More sharing options...
thescientist Posted December 18, 2010 Share Posted December 18, 2010 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 More sharing options...
boen_robot Posted December 18, 2010 Share Posted December 18, 2010 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 More sharing options...
jeffman Posted December 18, 2010 Share Posted December 18, 2010 Does your script call session_start()? Any script that wants access to session data must call it. (Not every file that is included, however.) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.