Jump to content

SESSION not being set


doubledee

Recommended Posts

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
Share on other sites

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
Share on other sites

<?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?  :confused:

 

 

Debbie

 

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.