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) { Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Solution CroNiX Posted December 3, 2014 Solution Share Posted December 3, 2014 do a var_dump of $_SESSION to see what session holds Quote Link to comment 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) } Quote Link to comment 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) } Quote Link to comment Share on other sites More sharing options...
LeJack Posted December 3, 2014 Share Posted December 3, 2014 (edited) 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. Edited December 3, 2014 by LeJack Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.