首页 > 解决方案 > 当我使用 PHP 更改页面时,我的 URL 没有更新,我该如何解决这个问题?

问题描述

我有一个登录表单,您可以在其中登录,但它不能正常工作。我怀疑它是由于 JQuery Mobile 造成的。当我注销时,我进入主登录页面,但我的 URL 仍然是 logout.php (一个破坏会话的文件,然后使用 header(location) 将用户重定向到登录)并且我无法再登录,因为我的页面被卡住了. 当我刷新这得到解决。但是当我尝试登录时,URL 仍然是 login.php。当我现在刷新时,我被重定向回 l​​ogin.php。刷新在这里不起作用。我怎样才能解决这个问题?过去一切正常,但现在不行了。

<head>
<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Hondensectie</title>
    <link rel="stylesheet" href="themes/themerollertest.min.css" />
    <link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" />
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" />
    <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
    <link type="text/css" rel="stylesheet" href="css/style.css"/>
</head>

上面你可以看到头部

 <?php   
 session_start();  
 session_destroy();  
 header("location: login.php"); 
 ?>  

上面你看到logout.php

标签: phpjquerysessionurllogin

解决方案


<?php   
session_start();  
$des = session_destroy();  
if($des) {
    header("Location: login.php"); 
}
?>  

推荐阅读