php中session退出登陆问题_PHP

WBOY
Release: 2016-06-01 11:56:11
Original
721 people have browsed it

在php中,如果使用的session来判断用户是否登陆,退出时,则可以如此:

session_start();
session_destroy();

会话即表示已经结束。下一句话应该写js,使页面跳转了。

<script>alert("已经退出登陆!");location.href="login.php";</script>

如果是个框架页呢,就不要直接用location了。因为这样会在一个小框架页内跳转,本意一定是要整个框架都跳转过去啊。所以location前要加上"parent."。

全部过程如下(只对框架页的来说):
复制代码 代码如下:
session_start();
session_destroy();
//为使框架整个页面跳转到登陆页
echo "<script>alert('已经退出登陆');parent.location.href='login.php';</script>";
?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!