Jump to content

IF / Else / Echo Statements = Chaos. PLEASE HELP!!!


Reece S

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

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