0
我在PHP中有一個cookie,如果它存在,頁面應該轉到用戶頁面而不要求登錄,但它不起作用。這是安寧我的警告: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();
?>
在類USUARIOS功能:
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」;',並在應我把餅乾訪問它?我關閉並打開瀏覽器後不應該工作嗎? – anuseranother
@anuseranother你看過檢查你的cookie是否被設置?通過在PHP中執行'print_r($ _ COOKIE);'或檢查您的「檢查元素」 - >「資源」方式。 – Darren
這是printin'我的cookie的價值,這是usr的名稱。 – anuseranother