Zephyris Posted February 19, 2011 Share Posted February 19, 2011 I'm trying to make a page with multiple $_GET situations example if my user wants to log out, he clicks the loggout link which sends him to user.php?v=dc if($_GET['v']=="dc") { session_destroy(); exit; } if(isset($_GET['v'])=="dc") { session_destroy(); exit; } but it seems no matter where the user goes it destroys the session. if($_GET['v']=="mail") { // show mail } but instead it does what's in $_GET['v']=="dc" <?php if(isset($_GET["v"])=="dc"){ if($_SESSION[user]=='Guest'){ echo "You are not logged in fool."; exit; }else{ echo "Session closed!"; session_destroy(); } } ?> That above doesn't work, when I go elsewhere it still destroy the session... no matter if it's a guest or not. If I go to ($_GET['v']=="godknows") as a user and not a guest, it will destroy the session. I get the strangest errors... S.O.S Link to comment https://forums.phpfreaks.com/topic/228154-if-_get-_session-not-listening-to-me-lol/ Share on other sites More sharing options...
chaseman Posted February 19, 2011 Share Posted February 19, 2011 to me, your script is saying "if he's not a guest" -> log him out, and that's what happens to you, you're a user, so you're being logged out because you're not a guest. == guest // I'm NOT a guest I'm a user, so I go down to the else part else { session_destroy(); } Maybe I misunderstood your situation, but that's how I got it. Link to comment https://forums.phpfreaks.com/topic/228154-if-_get-_session-not-listening-to-me-lol/#findComment-1176561 Share on other sites More sharing options...
PaulRyan Posted February 19, 2011 Share Posted February 19, 2011 Are you actually setting $_SESSION['user']? Try the following: <?php if(isSet($_GET['v']) && $_GET['v'] == 'dc') { if(isSet($_SESSION['user'])) { if($_SESSION['user'] == 'Guest') { echo 'You are not logged in fool.'; } else { echo "Session closed!"; } } else { echo '$_SESSION[\'user\'] is not set!'; } } ?> Regards, PaulRyan. Link to comment https://forums.phpfreaks.com/topic/228154-if-_get-_session-not-listening-to-me-lol/#findComment-1176563 Share on other sites More sharing options...
Zephyris Posted February 19, 2011 Author Share Posted February 19, 2011 Variables were all set, I just removed the isset from my $_GET["v"]=='dc' and that fixed it. I also tried ur (isSet($_GET['v']) && $_GET['v'] == 'dc') which also worked. Thanks PaulRyan Link to comment https://forums.phpfreaks.com/topic/228154-if-_get-_session-not-listening-to-me-lol/#findComment-1176570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.