I am trying to set in two cookies the time expired

A

Anonymous

Guest
Hello
I am trying to set in two cookies the time expired

setcookie ("password", $PHP_AUTH_PW,time()+3600);
setcookie ("username", $PHP_AUTH_USER,time()+3600);

But I am doing something wrong
Can you please help me!

Also I want to make a log out page that will delete instantly these cookies, do you have any ideas?

Thank you!



Code:
<?php

require("config.php");
$realm = 'CONTROL PANEL';
$errormsg = 'You are not authorized';

$connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting");	
mysql_select_db($db_name, $connection);

$query = "SELECT * from upl";
$result = mysql_query($query, $connection);

$username = mysql_result($result, 0, "username");
$passwd = mysql_result($result, 0, "password");

function authenticate($realm, $errormsg) {
    header ("WWW-Authenticate: Basic realm=\"$realm\"");
    header ("HTTP/1.0 401 Unauthorized");
    echo "<b><center>$errormsg</center></b>";
    exit;
  }
  
  
	   if ((isset($PHP_AUTH_PW, $PHP_AUTH_USER)) && $PHP_AUTH_USER != $username && $PHP_AUTH_PW != $passwd) {
	   
	   
	   
	   $sendTo = "admin@***.com";

$name = 'CONTROL PANEL';
$email = 'admin@***.com';
$subject = "PASSWORD REMINDER";
//$headers = "From: " . $_POST["namel"] ." ". "<" . $_POST["email"] .">\r\nContent-Type: text/html; 
$headers = "From: " . $name ." ". "<" . $email .">\r\nContent-Type: text/html; 

charset=windows-1253";

$messagel = 'CONTROL PANEL PASSWORD REMINDER' . '<br><b>Username:</b> ' . $username . '<br><b>Password:</b> ' . $passwd;


mail($sendTo, $subject, $messagel, $headers);
	   
	   }

  
  
  

if ( (!isset($PHP_AUTH_USER)) || ! (($PHP_AUTH_USER == $username) && ( $PHP_AUTH_PW == $passwd)) ) {
	authenticate ($realm, $errormsg);
	
	
	}
	
setcookie ("password", $PHP_AUTH_PW,time()+3600);
setcookie ("username", $PHP_AUTH_USER,time()+3600);

	   
	   
	   
       header('Location: photos_update.php');
       exit;










?>
 
Code:
<?php

// Make it this way:
setcookie(...
// Instead of:
setcookie (...

?>
Also check if you have cookies enabled in your browser.
To unset all cookies you can use:
Code:
<?php

unset($_COOKIE);

?>
This will destroy all cookies set by your site.
If you want to unset a specific cookie you can do:
Code:
<?php

setcookie('password', '', 0);

?>
 
Back
Top