-2
after more than 20 years without programming in PHP, I decided to make a "system" of scheduling clients for my girlfriend. But I am going through a problem that is leaving me with more gray hair. (rs)
$("#form_validation").click(function(){
var username = $("#usuario").val().trim();
var password = $("#password").val().trim();
if(username == "" || password == ""){
$("#modal_erro1").slideDown();
setTimeout(function() {
$('#modal_erro1').fadeOut('fast');
}, 3000);
}else{
$.ajax({
url:'includes/login.php',
type:'post',
data:'usuario='+username+'&senha='+password,
crossDomain: true,
success:function(response){
if(response == 1){
window.location.href="index.php";
}else{
$("#modal_erro1").slideDown();
setTimeout(function() {
$('#modal_erro1').fadeOut('fast');
}, 3000);
result.innerHTML="";
}
}
});
}
});
<?php
include('../../includes/conect.php');
$usuario = $_POST["usuario"];
$password = $_POST["senha"];
$senha = hash('sha256', $password);
$sql_user = "select id,user,pass from admin where user = '{$usuario}' and pass='{$senha}' limit 1";
$result_user = $conn->query($sql_user);
if ($result_user->num_rows > 0) {
echo "1";
$id_client = $result_user["id"];
setcookie("id",$id_client,"",'/');
}else{
echo "0";
}
mysqli_close($conn);
?>
What happens is that the Cookie is not saved.
And another strange fact is that if I change the position echo within login.php, the answer returns null
Someone could give me a direction?
The cookie is not saved and certainly the login is not done. Already confirmed if the login performs? it enters inside this if?
– BRABO
Hello @BRABO thanks for the reply. Yes it enters inside the if and login is done. Testing includes/login.php page in GET
– Erick de Abreu Gomes