Hello people I am doing the part of "Keep the session started" in the following way: two cookies are created, one with the user and the other with a series of random numbers (which are a field of the user table) , the problem that I have is that when the cookie of the series of numbers sets it to me, it does so with a value that is no longer in the table, that is, the cookie always keeps the previous value that was in the table and never the current .. then they never coincide with me and therefore it does not work for me
Example of the PROBLEM: current value of cookie_login in the users table is 565, then the user if logue with the option "keep session started" this value is updated to another .. for example 124, but the cookie stays with the value 565 and I do not know why he does that .. would believe that it is because the cookie is on the client side and then it is never synchronized in real time with the server .. but how can I solve it?
I attach the code:
if($a->ConectarUser($_POST['user'],$_POST['pass'])==1)
{
echo "Se ha logueado correctamente";
if ($_POST["recordame"]=="1") //es que pidió memorizar el usuario
{
//busco el id del usuario que hizo Esto , lo saco del metodo ConectarUser, el cual ya creò una sesion con el idusuario
$iduser=intval($_SESSION["idUsuario"]);
//1) creo una marca aleatoria en el registro de este usuario
//alimentamos el generador de aleatorios
mt_srand (time());
//generamos un número aleatorio
$numero_aleatorio = mt_rand(1000000,999999999);
//2) meto la marca aleatoria en la tabla de usuario
//3) ahora meto una cookie en el ordenador del usuario con el identificador del usuario y la cookie aleatoria
setcookie("idusuario", $iduser , time()+(60*60*24*365));
setcookie("marca_aleatoria_usuario_dw", $numero_aleatorio, time()+(60*60*24*365));
$a->cargar_cookie_user($numero_aleatorio,$iduser);
echo $_COOKIE['idusuario'];
echo $_COOKIE['marca_aleatoria_usuario_dw'];
}
header('Location: ../main.php');
}
greetings