Jump to content


Photo

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


  • Please log in to reply
1 reply to this topic

#1 firelior

firelior
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 22 September 2006 - 10:43 PM

Hi,
I got this 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>

	";
}

?>

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

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 September 2006 - 02:51 AM

just expire the cookie. for fun, you can remove its value, too.

@setcookie("username", "", 1);




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users