PHP链接到session_destroy [英] PHP Link to session_destroy

查看:80
本文介绍了PHP链接到session_destroy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个链接,点击后将在php中运行:

I need to make a link that when clicked will run this in php:

session_destroy();

我知道如何在html中建立链接,但我不知道如何让它互动用PHP。感谢您的帮助。

I know how to make a link in html, but I don't know how to make it interact with php. Thanks for any help.

推荐答案

例如,您希望使用此脚本进行注销。

For an example, you want to use this script for logging out.

你的HTML必须是这样的index.php(只是一个例子)

Your HTML has to be something like this for "index.php" (just an example)

<a href="logout.php">Log Out</a>

然后在logout.php

Then on the "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,我也可以告诉你吗?

In case you want to use JavaScript, I can tell you that too?

这篇关于PHP链接到session_destroy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆