在php中注销和重定向会话 [英] logout and redirecting session in php

查看:103
本文介绍了在php中注销和重定向会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的一个是我的php站点中的链接..单击此按钮后,用户的会话应终止,并且他应再次重定向到主页..我编写了此概念的编码,如下所示,但它显示了我只有一个空白页(它不会重定向到主页). 请更正我的编码

the below one is the link in my php site.. after clicking this button the user's session should be terminated and he should be redirected again to the home page.. i have written the coding for this concept as follows but it shows me only a blank page(it is not redirected to the home page).. please correct my codings

<a href="Logout.php">
click here to log out</a>

Logout.php中的编码如下

codings in the Logout.php a follows

<?
session_start();
session_unset();
session_destroy();
ob_start();
header("location:home.php");
ob_end_flush(); 
include 'home.php';
//include 'home.php';
exit();
?>

推荐答案

这仅是必需的

session_start();
unset($_SESSION["nome"]);  // where $_SESSION["nome"] is your own variable. if you do not have one use only this as follow **session_unset();**
header("Location: home.php");

这篇关于在php中注销和重定向会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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