doubledee Posted August 23, 2011 Share Posted August 23, 2011 Why is my SESSION not getting set in the code below?! <?php // Initialize a session. session_start(); // Initialize Logged-In Status. $_SESSION['loggedIn'] = FALSE; // Display Logged-In Status. echo '<p>$_SESSION[\'loggedIn\'] = ' . $_SESSION['loggedIn'] . '</p>'; exit(); When I run this I get... $_SESSION['loggedIn'] = Debbie Link to comment https://forums.phpfreaks.com/topic/245478-session-not-being-set/ Share on other sites More sharing options...
Pikachu2000 Posted August 23, 2011 Share Posted August 23, 2011 var_dump($_SESSION['loggedIn']); Link to comment https://forums.phpfreaks.com/topic/245478-session-not-being-set/#findComment-1260797 Share on other sites More sharing options...
doubledee Posted August 23, 2011 Author Share Posted August 23, 2011 var_dump($_SESSION['loggedIn']); I actually tried setting it to "TRUE" and "FALSE" and the branching that depends on $_SESSION['loggedIn'] seems to be working, but why isn't the value being echoed?! Debbie Link to comment https://forums.phpfreaks.com/topic/245478-session-not-being-set/#findComment-1260798 Share on other sites More sharing options...
Pikachu2000 Posted August 23, 2011 Share Posted August 23, 2011 Because it isn't a string, it's a boolean. A true value should echo 1, a false will echo nothing. if( $_SESSION['loggedIn'] === TRUE ) { echo 'True'; } if( $_SESSION['loggedIn'] === FALSE ) { echo 'False'; } Link to comment https://forums.phpfreaks.com/topic/245478-session-not-being-set/#findComment-1260799 Share on other sites More sharing options...
doubledee Posted August 23, 2011 Author Share Posted August 23, 2011 Because it isn't a string, it's a boolean. A true value should echo 1, a false will echo nothing. if( $_SESSION['loggedIn'] === TRUE ) { echo 'True'; } if( $_SESSION['loggedIn'] === FALSE ) { echo 'False'; } Why doesn't FALSE echo as zero (0)??? Debbie Link to comment https://forums.phpfreaks.com/topic/245478-session-not-being-set/#findComment-1260800 Share on other sites More sharing options...
darkfreaks Posted August 23, 2011 Share Posted August 23, 2011 <?php // Initialize a session. session_start(); function login() { $_SESSION['loggedIn'] = TRUE; } // Display Logged-In Status. echo login(); ?> Link to comment https://forums.phpfreaks.com/topic/245478-session-not-being-set/#findComment-1260816 Share on other sites More sharing options...
doubledee Posted August 23, 2011 Author Share Posted August 23, 2011 <?php // Initialize a session. session_start(); function login() { $_SESSION['loggedIn'] = TRUE; } // Display Logged-In Status. echo login(); ?> I don't get it? Someone said earlier that TRUE should echo as "1"? Any other language I've ever programmed in would display a BOOLEAN? Debbie Link to comment https://forums.phpfreaks.com/topic/245478-session-not-being-set/#findComment-1260820 Share on other sites More sharing options...
darkfreaks Posted August 23, 2011 Share Posted August 23, 2011 yes so if the session is set as TRUE or 1 the user should be logged in. Link to comment https://forums.phpfreaks.com/topic/245478-session-not-being-set/#findComment-1260822 Share on other sites More sharing options...
doubledee Posted August 23, 2011 Author Share Posted August 23, 2011 yes so if the session is set as TRUE or 1 the user should be logged in. Are you baiting me and trying to start a fight?? Debbie Link to comment https://forums.phpfreaks.com/topic/245478-session-not-being-set/#findComment-1260829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.