Jump to content

SESSION not being set


doubledee
 Share

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

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.