我需要创建一个链接,点击后将在 php 中运行:
session_destroy();
我知道如何在 html 中创建链接,但我不知道如何使其与 php 交互。感谢您的帮助。
最佳答案
例如,您想使用此脚本进行注销。
“index.php”的 HTML 必须是这样的(只是一个例子)
<a href="logout.php">Log Out</a>
然后在“logout.php”上
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
header("location:index.php"); //to redirect back to "index.php" after logging out
exit();
如果你想使用 JavaScript,我也可以告诉你吗?
关于hyperlink - PHP 链接到 session_destroy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2889434/