';window.location.replace';重定向到给定页面,但从php破坏会话(仅限Chrome)?
我知道这个问题有点令人困惑,但情况就是这样 我有以下Ajax功能:';window.location.replace';重定向到给定页面,但从php破坏会话(仅限Chrome)?,php,javascript,ajax,google-chrome,Php,Javascript,Ajax,Google Chrome,我知道这个问题有点令人困惑,但情况就是这样 我有以下Ajax功能: $.ajax({ url:"../controllers/xx_register.php", type:"POST", data:send, success: function(response){ if (response=="1") { window.location.replace("http://localhost/Underground/0
$.ajax({
url:"../controllers/xx_register.php",
type:"POST",
data:send,
success: function(response){
if (response=="1") {
window.location.replace("http://localhost/Underground/01.InProgress/ES-dictionary/public/index.php");
return true;
}
else{
$('#error').append(response);
}
},
error: function(){
$('#error').append('Fatal error!');
}
});
return false;
xx_register.php文件:
$arr=$_POST;
$reg = registerMe($arr);
if ($reg === true) {
$_SESSION['is_logged']=$arr['username'];
echo 1;
exit();
}
else{
echo($reg);
exit();
}
最后是index.php
session_start();
if (isset($_SESSION['is_logged'])) {
header("Location: ../views/start.php");
exit();
}
else{
header("Location: ../views/login.php");
exit();
}
很快-想法:
我使用ajax函数注册新用户。如果注册一切正常,用户将被重定向到index.php
。由于$\u会话['is_logged']
存在,用户将被重定向到start.php
页面
这一切都适用于FireFox 21、IE 10、Safari 5.1,但在Chrome 27上情况完全不同——用户再次被重定向到loggin.php
。简单的逻辑是,window.location.replace
重定向到index.php
并清除会话。我真的看不出任何解释。
两个问题:
1.关于窗口.位置.更换的问题我是否正确?
2.如何修复它
非常感谢。不要为此使用.replace()
,直接赋值即可
这是一个补丁:
window.location = "http://localhost/Underground/01.InProgress/ES-dictionary/public/index.php";
谢谢你的建议。它不再起作用了,但我发现了原因。我把饼干关掉了。真不敢相信,因为这么简单的事情,花了这么多时间,甚至浪费了你和所有其他人的时间。