我正在尝试销毁所有表单会话,如下所示:我有一个侧边导航.php栏,当用户单击它时,它会转到此页面:
<?php
session_start();
unset($_SESSION['applicationID']);
session_destroy();
echo'<html><script>window.location="index.php?url=newapplication&id="'.$userid.';</script></html>';
?>
这反过来又会调出新的申请表,但是,"$userid"
没有回声。 它返回为空白。 有什么想法吗?
**$userid ** 需要(您没有选择)定义才能使用它。
您在主脚本中定义的任何内容都将保留在那里,因为该脚本已完成其执行时间。
您可以通过 GET、POST、SESSION 或 COOKIE 传递该值。否则,您将不得不在数据库中挖掘该用户名,但话又说回来,您需要"保留"一个会话或一个"返回"的数字才能搜索它。
如果您在 SESSION 中定义了 userid 变量,您实际尝试执行的操作可能如下所示:
<?php
session_start();
unset($_SESSION['applicationID']);
echo'<html><script>window.location="index.php?url=newapplication&id='.$_SESSION['userid'].'"';
session_destroy();
echo '</script></html>';
?>
您在$userid
之前已关闭window.location
。上述代码的输出将是
<html><script>window.location="index.php?url=newapplication&id="the_value_of_$userid;</script></html>
使用以下代码
<?php
session_start();
unset($_SESSION['applicationID']);
session_destroy();
echo'<html><script>window.location="index.php?url=newapplication&id='.$userid.'";</script></html>';
?>
希望这对你有帮助