会话无法使用php工作
当我登录index.php时,页面会重定向到dashboard.php,但当我按back page时,它仍会重定向index.php,但在我的代码中,当会话仍然存在时,即使我单击back page,它也会重定向到dashboard.php而不是index.php,但它不工作 index.php会话无法使用php工作,php,session,Php,Session,当我登录index.php时,页面会重定向到dashboard.php,但当我按back page时,它仍会重定向index.php,但在我的代码中,当会话仍然存在时,即使我单击back page,它也会重定向到dashboard.php而不是index.php,但它不工作 index.php 警报(“登录成功”); window.location='dashboard.php'; dashboard.php 仪表板 session.php window.location='index
警报(“登录成功”);
window.location='dashboard.php';
dashboard.php
仪表板
session.php
window.location='index.php';
我建议您使用php进行这些类型的重定向
header('Location: http://www.example.com/');
这可能是解决方案
echo "<script>.....</script>";
echo“…”;
你忘了使用echo了,哈哈哈,太谢谢你了,我压力很大,我不认为这是我代码的问题。谢谢你,我的朋友!尽量不要在重定向之类的东西上使用javascript,因为javascript不可靠。只使用块引号作为实际的引号,并使用粗体作为强调,而不是为了吸引注意,所以请删除它。
<?php if(!isset($_SESSION)){
session_start();
} ?>
<?php
if (!isset($_SESSION['id']) || (trim($_SESSION['id']) == '')) {
?> <script>window.location='index.php';</script> <?php
exit();
}
$session_id=$_SESSION['id'];
?>
header('Location: http://www.example.com/');
echo "<script>.....</script>";