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.

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.

 

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.

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.