Jump to content

session and cookie-login-help(should be simple)


firelior

Recommended Posts

Hi,
I got this code:
[code]
<?
session_start();
#########################
##Here it always exits!##
#########################
if(isset($_COOKIE['username']) || isset($_COOKIE['password'])){
exit(<p><a href="login.php?log=1">logout</a>);
}
//here it should log out
if(isset($_GET['log'])==1){
setcookie ("username", "admin", time() - 4000);
setcookie ("password", "admin", time() - 4000);
}

if(isset($_POST['username']) || isset($_POST['password']))
{

if($_POST['username']==$Ausername || $_POST['username']==$Apassword)
{
if(isset($_POST['remember']))
{
@setcookie("username", $_POST['username'], time() + 3600);
@setcookie("password", $_POST['password'], time() + 3600);
$_SESSION['username']=$Ausername;
$_SESSION['password']=$Apassword;
}
else
{
@setcookie('username', $_POST['username']);
@setcookie('password', $_POST['password']);
$_SESSION['username']=$Ausername;
$_SESSION['password']=$Apassword;
}

}
else die($lang->invalidup.'<p><a href="login.php">Go Back</a>');
}

else
{
echo "

<form method='post' action='login.php'>
Username: <input type='text' name='username'>
<br>Password: <input type='password' name='password'>
<br><input type='checkbox' name='remember'>Remember me on this computer
<p><input class='button' type='submit' value='Login'>
</form>

";
}

?>[/code]

Now, My problem is that it always exists in the line I told you above..
I cant destroy the cookie.
Please help me destroy the cookie
thanks!!
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.