Well the thing is that I'm setting up a remind me, but I do not want to work and I do not know why.
Look at the codes:
This is the view, that if it has variable sessions it should be redirected, it should
<?php
// Start the session
session_start();
if (isset($_SESSION["nickname"])) {
header('Location: home.iq');
}
else if (isset ($_COOKIE["nickname"] ) ) {
$_SESSION['nickname'] = $_COOKIE["nickname"];
header('Location: home.iq');
}
echo "cookies: ".$_COOKIES["nickname"];
echo "cookie: ".$_COOKIE["nickname"];
echo "sesion :".$_SESSION["nickname"];
?>
<link href="../../css/administrator/admin.css" rel="stylesheet" >
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="card card-container" style="background: grey">
<img class="profile-img-card" src="../../images/iq-adentro.png" alt="" width="50" height="50" />
<p id="profile-name" class="profile-name-card"></p>
<form class="form-signin" action="../../controllers/administrator/" method="POST">
<span id="reauth-email" class="reauth-email"></span>
<input type="email" name="username" id="username" class="form-control" placeholder="Nombre de usuario" required autofocus>
<input type="password" name="password" id="password" class="form-control" placeholder="Password" required>
<div id="remember" class="checkbox">
<label>
<input type="checkbox" value="remember-me" name="remember" id="remember"> Recuerdame
</label>
</div>
<button class="btn btn-lg btn-primary btn-block btn-signin" type="submit">Iniciar sesion</button>
</form><!-- /form -->
<a href="#" class="forgot-password">
<!-- Olvidaste tu contraseña?-->
</a>
</div><!-- /card-container -->
</div><!-- /container -->
</div>
this is the controller
<?php
$link = mysqli_connect("localhost", "colitaly_pru", "A[,nMbXao(lS");
mysqli_select_db($link, "colitaly_pantallas");
$tildes = $link->query("SET NAMES 'utf8'"); //Para que se muestren las tildes correctamente
$username=$_POST['username'];
$password=$_POST['password'];
$result = mysqli_query($link, "SELECT * FROM users WHERE username='$username' AND password='$password'");
if ($fila = mysqli_fetch_array($result)){
session_start();
$_SESSION['nickname']= $username;
if(isset($_POST['remember'])){
setcookie ("nickname",$use, time()+60);
echo "se guardo";
}
header('Location: ../../views/administrator/home.iq');
}else {
header('Location: ../../views/administrator/admin.html');
}
?>
When I close session this is done:
<?php
session_start();
unset($_SESSION["nickname"]);
header('Location: ../../admin');
?>
But when you return to the view this is what you see: