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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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... ::)

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.