-1

已弃用:第 37 行的 /home/socia125/public_html/logout.php 中已弃用函数 session_is_registered()

警告:无法修改标头信息 - 第 38 行 /home/socia125/public_html/logout.php 中的标头已由(输出开始于 /home/socia125/public_html/logout.php:37)发送

这是我正在使用的代码

<?php

session_start();
// Force script errors and warnings to show on page in case php.ini file is set to not     
display then
error_reporting(E_ALL);
ini_set('display_errors', '1');

// Unset all of the session variables
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie
if (isset($_COOKIE['idCookie'])) {
setcookie("idCookie", '', time()-42000, '/');
setcookie("passCookie", '', time()-42000, '/');
 }
 // Destroy the session variables
 session_destroy();
 // Check to see if their session is in fact destroyed
 if(!session_is_registered('firstname')){ 
 header("location: index.php"); // << makes the script send them to any page we set
 } else {
 print "<h2>Could not log you out, sorry the system encountered an error.</h2>";
  exit();
  } 
  ?> 
4

1 回答 1

2

只需检查是否设置了会话变量:

if(!session_is_registered('firstname')){ 

变成

if (!isset($_SESSION['firstname'])) {
于 2012-06-11T13:48:33.770 回答