Reece S Posted January 1, 2008 Share Posted January 1, 2008 Hi there, I am new to this forum, and I hope to get to know your all reasonably well. I have been having a few problems with this short php script, Logically, it should work, but Technically, it does'nt. Here it is... <?php if($session->logged_in) { echo "logged in"; }else{ echo "Logged Out"; } ?> Any Ideas? Also, I tried using if (isset($_SESSION["username"])) But with no luck. Hope someone can help, because I am out of ideas. Thanks in Advance. Quote Link to comment https://forums.phpfreaks.com/topic/84032-if-else-echo-statements-chaos-please-help/ Share on other sites More sharing options...
teng84 Posted January 1, 2008 Share Posted January 1, 2008 echo your session to check if you really set it properly and be sure you have session start at the top of your page Quote Link to comment https://forums.phpfreaks.com/topic/84032-if-else-echo-statements-chaos-please-help/#findComment-427655 Share on other sites More sharing options...
Daniel0 Posted January 1, 2008 Share Posted January 1, 2008 Well, there is nothing wrong with the code you posted. You need to test that $session->logged_in is being defined properly. Quote Link to comment https://forums.phpfreaks.com/topic/84032-if-else-echo-statements-chaos-please-help/#findComment-427658 Share on other sites More sharing options...
revraz Posted January 1, 2008 Share Posted January 1, 2008 page1.php <?php session_start(); $_SESSION["username"]="Fred"; ?> page2.php <?php session_start(); if (isset($_SESSION["username"])) { echo "logged in"; }else{ echo "Logged Out"; } ?> If this doesn't work, check that your session save path is correct in your php.ini file. Quote Link to comment https://forums.phpfreaks.com/topic/84032-if-else-echo-statements-chaos-please-help/#findComment-427661 Share on other sites More sharing options...
Reece S Posted January 2, 2008 Author Share Posted January 2, 2008 I am shocked! I have been groaning about this code for days to anyone that would listen, and it was a simple error of the "Include" statement with the wrong URL, and that "session_start" statement as mentioned. This is utterly rediculous, how could I have missed this? Anyway, thank you so much, and feel free to call me whatever you want, cuzz I deserve it, lol. Thank you so much, and thanks for the quick reply. Quote Link to comment https://forums.phpfreaks.com/topic/84032-if-else-echo-statements-chaos-please-help/#findComment-427669 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.