-1

非推奨:関数session_is_registered()は、37行目の/home/socia125/public_html/logout.phpで非推奨になりました。

警告:ヘッダー情報を変更できません-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 に答える