У меня есть файл cookie на PHP, если он существует, страница должна перейти на страницу пользователя без запроса логина, но это не сработает. Это предупреждение:Cookie не работает должным образом
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies.
Куки разрешены, и мой файл cookie существует, я проверил его.
Вот мой код входа (он работал до печенья):
<?php
include_once '../usersDB.php';
include_once '../usersFunctions.php';
$conexao = new usuarios();
$mail = $_POST["con1"];
$pass = $_POST["con2"];
$usuario = $conexao->buscarUsers("select * from users where email = '{$mail}' and senha = '{$pass}'");
if(isset($_POST['mantemLog']) && $_POST['mantemLog'] == "1"){
setcookie("mantemUsr",$_POST["con1"],time()+60*60*24*30);
}
if($usuario != null || isset($_COOKIE['mantemUsr'])){
$_SESSION["sucesso"] = "Usuario logado com sucesso";
loggingUsr($mail);
header("Location: slides.php");
}else{
$_SESSION["deny"] = "Usuario ou senha invalidos!";
header("Location: view.php");
}
die();
?>
Функция в классе Юзеров:
function buscarUsers($query){
$conexao = mysql_connect($this->host, $this->usuario, $this->senha);
mysql_select_db($this->banco, $conexao);
$result = mysql_query($query, $conexao);
$usr = mysql_fetch_assoc($result);
return $usr;
mysql_close($conexao);
}
HTML-:
<div id="logFrm">
<h5>Por favor, insira o seu email<br />
e senha para continuar.</h5>
<form action="acessa.php" method="POST">
<label for="con1" class="lblLog">Email</label>
<input type="text" name="con1" id="con1" />
<br /><br />
<label for="con2" class="lblLog">Senha</label>
<input type="password" name="con2" id="con2" />
<br /><br />
<input type="submit" name="logBtn" id="logBtn" value="Logar" />
<label for="chk">
<input type="checkbox" name="mantemLog" id="mantemLog" value="1" />Manter logado</label>
</form>
И index.php:
<?php
require_once("acessa.php");//calls the login code
require_once("view.php");//calls the html
Я начала сессии в 'include_once«../ usersFunctions.php»; ', и где должен Я помещаю файлы cookie для доступа к нему? Должна ли она работать после закрытия и открытия браузера? – anuseranother
@anuseranother Вы посмотрели, что ваш cookie установлен? либо выполнив 'print_r ($ _ COOKIE);' в PHP, либо проверив свой «Элемент проверки» -> «Ресурсы». – Darren
Это печать моего значения cookie, то есть имя usr. – anuseranother