我在根文件夹中有以下index.php
文件。实际的网站位于子目录中,并在用户登录后被访问。我的问题是当用户关闭选项卡而不是浏览器时,会话未终止。
当他们回到网站时,它会要求他们登录,但他们已经登录,因此登录功能不起作用,不会将它们重定向到实际网站。我看到浏览器正在跟踪sessionid。我是网络开发的新手。
如何检查会话是否已录制,如果已重定向到其他网址?谢谢
这是脚本的一部分,其余部分只是html,文本字段等,以使登录页面看起来不错,并接受用户信息。
<script type="text/javascript"><!--
$('#button-cart').on('click', function() {
$.ajax({
url: 'login/index.php?route=account/loginajax',
type: 'post',
data: $('input[type=\'text\'], input[type=\'password\']'),
dataType: 'json',
beforeSend: function() {
$('#button-cart').button('loading');
},
complete: function() {
$('#button-cart').button('reset');
},
success: function(json) {
$('.alert, .text-danger').remove();
$('.form-group').removeClass('has-error');
if (json['error']) {
$('.error').after('<div class="alert alert-danger has-error">' + json['error'] + '</div>');
}
if (json['success']) {
$('.error').after('<div class="alert alert-success">' + json['success'] + '</div>');
window.location = "http://www.mbdtesting.com/login/index.php? route=account/account";
}
}
});
});
</script>
答案 0 :(得分:0)
尝试将这样的内容放在您拥有的每个网页的顶部
<? php
session_start();
if (isset($_SESSION['admin_id'])) {
header("location: home.php");//the path or url of the page you want the client to be redirected if the session is set.
exit();
}
?>