Mirad lo que quiero es que si un usuario "aprieta"el cuadrado "remember"se le ponga una cookie en el PC.
asi lo tengo hecho:
el archivo login:
Código PHP:
<?
session_start();
if(isset($SESSION)){
header("location: index.php");
} else {
if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){
$_SESSION['nombre'] = $_COOKIE['cookname'];
$_SESSION['password'] = $_COOKIE['cookpass'];
header("location: index.php");
} else {
?>
<html> <head> <title>Identificate</title> </head>
<body>
<center>
</center>
<form action="comprueba.php" method="POST">
<table width="322" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="322" height="28" valign="top">Login:
<input type="text" name="login">
</td>
</tr>
<tr>
<td valign="top" height="21">Password:
<input type="password" name="pass">
</td>
</tr>
<tr>
<td height="14" valign="top"><input type="checkbox" name="remember">
Recordarme en mi proxima visita</td>
</tr>
<tr>
<td height="40"></td>
</tr>
</table>
<input type="submit" value="Entrar">
</form>
</body>
</html>
<?
}
}
?>
Código PHP:
<?
$server="localhost";
$database="nombre";
$dbpass="";
$dbuser="mysql";
$query="SELECT * FROM usuarios WHERE login='$login'";
$link=mysql_connect($server, $dbuser, $dbpass);
$result=mysql_db_query($database, $query, $link);
if(mysql_num_rows($result)==0){
echo "No existe el login introducido";
} else {
$array=mysql_fetch_array($result);
session_start();
if($array["password"]==crypt($pass, "semilla") ){
$SESSION["login"]=$login;
$SESSION["nombre"]=$array["nombre"];
$SESSION["apellidos"]=$array["apellidos"];
$SESSION["id"]=$array["id"];
session_register("SESSION");
if(isset($array['remember'])){
setcookie("cookname", $_SESSION['nombre'], time()+60*60*24*100, "/");
setcookie("cookpass", $_SESSION['password'], time()+60*60*24*100, "/");
}
header("location: index.php");
} else {
echo "Password incorrecto!";
}
}
?>
thanks