Jump to content

[SOLVED] Help with recognizing if we are logged in or not..


Cory94bailly

Recommended Posts

<?
if(isset($_COOKIE['ID_fcs_member']))
{
//Connect to Members DB
mysql_connect("***", "***", "***") or die(mysql_error());
mysql_select_db("***") or die(mysql_error());
//Look for the member cookies
$username = $_COOKIE['ID_fcs_member'];
$pass = $_COOKIE['Key_fcs_member'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//If the cookie exists, show the "Logout" button.
{
?>
<a href="logout.php">Logout</a>
<?
}
}
}
else

//If the cookie does not exist, show the "Login" button.
{
?>
<a href="login.php">Login</a>
<img src="images/splitter.gif" class="splitter" alt="" />
<?
}
?>
<?
if(isset($_COOKIE['ID_fcs_team']))
{
//Connect to Team DB
mysql_connect("***", "***", "***") or die(mysql_error());
mysql_select_db("***") or die(mysql_error());
//Look for the team cookies
$username = $_COOKIE['ID_fcs_team'];
$pass = $_COOKIE['Key_fcs_team'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//If the cookie exists, show the "Logout" button.
{
?>
<a href="logout.php">Logout</a>
<?
}
}
}
else

//If the cookie does not exist, show the "Login" button.
{
?>
<a href="login.php">Login</a>
<img src="images/splitter.gif" class="splitter" alt="" />
<?
}
?>

 

 

Well that's my whole "Loggedin.php"...

 

I obviously know I'm already doing it wrong..

 

Any help?

 

I tried grouping them together so it wouldn't show one "logout" and one "login" button but it didn't work when I tried..

you haven't made an IF statement

 

//If the cookie exists, show the "Logout" button.
{
?>
<a href="logout.php">Logout</a>
<?
}

 

should be

//If the cookie exists, show the "Logout" button.
if(cookie_name)
{
?>
<a href="logout.php">Logout</a>
<?
}

you haven't made an IF statement

 

//If the cookie exists, show the "Logout" button.
{
?>
<a href="logout.php">Logout</a>
<?
}

 

should be

//If the cookie exists, show the "Logout" button.
if(cookie_name)
{
?>
<a href="logout.php">Logout</a>
<?
}

 

That's not the exact point I am looking for...

 

I am technically looking for 4 different cookies and I don't know how to look for them all at the same time since 2 use one DB and 2 use another DB...

Use Sessions for starters cookies are gay

 

So basically you love those ?PHPSESSID= following by a long alphanumeric string on the end of all your URLs? Otherwise you might want to check up on how sessions work before making such bold statements... ::)

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.