Tom8001 Posted December 3, 2014 Share Posted December 3, 2014 I get this error Notice: Undefined index: loggedIn in C:\xampp\htdocs\Login\web_dir\index.php on line 6 The code for line 6 is if($_SESSION['loggedIn'] !== 1) { Link to comment https://forums.phpfreaks.com/topic/292870-undefined-index-error/ Share on other sites More sharing options...
CroNiX Posted December 3, 2014 Share Posted December 3, 2014 This was explained several times in your other thread. That session var hasn't been set yet, so it doesn't exist and you don't check to see if it exists before using it in a comparison statement. Link to comment https://forums.phpfreaks.com/topic/292870-undefined-index-error/#findComment-1498377 Share on other sites More sharing options...
Tom8001 Posted December 3, 2014 Author Share Posted December 3, 2014 This was explained several times in your other thread. That session var hasn't been set yet, so it doesn't exist and you don't check to see if it exists before using it in a comparison statement. It does exist, it is set when they log in. Link to comment https://forums.phpfreaks.com/topic/292870-undefined-index-error/#findComment-1498380 Share on other sites More sharing options...
Tom8001 Posted December 3, 2014 Author Share Posted December 3, 2014 Also it works, if im not logged in it tells me i'm not and if i am logged in it will let me continue, but the problem is it's saying Undefined index & i don't know why. Link to comment https://forums.phpfreaks.com/topic/292870-undefined-index-error/#findComment-1498381 Share on other sites More sharing options...
CroNiX Posted December 3, 2014 Share Posted December 3, 2014 do a var_dump of $_SESSION to see what session holds Link to comment https://forums.phpfreaks.com/topic/292870-undefined-index-error/#findComment-1498382 Share on other sites More sharing options...
Tom8001 Posted December 3, 2014 Author Share Posted December 3, 2014 This is what i got from the var_dump array(1) { ["loggedIn"]=> int(0) } Link to comment https://forums.phpfreaks.com/topic/292870-undefined-index-error/#findComment-1498384 Share on other sites More sharing options...
Tom8001 Posted December 3, 2014 Author Share Posted December 3, 2014 Also logging in with a user level of 0 array(3) { ["loggedIn"]=> int(1) ["user_level"]=> int(0) ["active"]=> int(1) } Link to comment https://forums.phpfreaks.com/topic/292870-undefined-index-error/#findComment-1498390 Share on other sites More sharing options...
LeJack Posted December 3, 2014 Share Posted December 3, 2014 You need to wrap this inside the isset if statement. If you just plain code it after the session is set, you'll get an error. Link to comment https://forums.phpfreaks.com/topic/292870-undefined-index-error/#findComment-1498394 Share on other sites More sharing options...
Tom8001 Posted December 3, 2014 Author Share Posted December 3, 2014 what isset statement i don't use one, like i said the session is automatically set when they log in. Link to comment https://forums.phpfreaks.com/topic/292870-undefined-index-error/#findComment-1498400 Share on other sites More sharing options...
LeJack Posted December 3, 2014 Share Posted December 3, 2014 *Face Palm* I'm not sure if he knows what he's doing. It's plain and simple. If you're not getting it, you won't learn it if we just give you the answers. If we're telling you to wrap something in something, you have to learn the coding jargon or you won't learn anything. I'm not going to give you the answers cuz I can clearly see what you're doing wrong. I'll just see if someone else will give you the answers and make you not understand the problem. Link to comment https://forums.phpfreaks.com/topic/292870-undefined-index-error/#findComment-1498401 Share on other sites More sharing options...
Tom8001 Posted December 4, 2014 Author Share Posted December 4, 2014 *Face Palm* I'm not sure if he knows what he's doing. It's plain and simple. If you're not getting it, you won't learn it if we just give you the answers. If we're telling you to wrap something in something, you have to learn the coding jargon or you won't learn anything. I'm not going to give you the answers cuz I can clearly see what you're doing wrong. I'll just see if someone else will give you the answers and make you not understand the problem. You don't even understand what i am saying. Link to comment https://forums.phpfreaks.com/topic/292870-undefined-index-error/#findComment-1498493 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.