I face some problem on my script that I use PHP and jquery to create login system.
First I have PHP page contain form for login. when user click submit I use jquery to send data to server
$.post('server_login.php', {username:username.val(), password:password.val()}, function(data){
alert(data);
});
in server_login.php I have function to doing login user.
if($_POST['username']=='username' && $_POST['password']=='1234'){
$expire = time() + 60*60*24*30; //1 month expired.
setcookie("user_id", $_POST['username'], $expire);
echo true;
}
and jquery alert "1" on my login page.
the problem is when i refresh my website and retieve cookie, it not show me.
print_r($_COOKIE);
anything wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…