Jump to content
php.lv forumi

header already sent + cookie


anonīms

Recommended Posts

logout.php

<?php

if(!$logged_in)
{
header ("Location: ".$BASE."");
}
else
{
if(isset($_COOKIE[$cookie_name])){
setcookie("".$cookie_name."","",time()-$cookie_time);
}


?>

 

Kādēļ 10 rindai met erorru par cookie already sent?

Apskatijos andrisp rakstu, bet tā īsti neko neatradu.

Edited by anonīms
Link to comment
Share on other sites

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/.../www/index.php:22) in /usr/home/.../www/pages/logout.php on line 10

 

pilns logout.php

<?php

if(!$logged_in)
{
header ("Location: ".$BASE."");
}
else
{
/*if(isset($_COOKIE[$cookie_name])){
setcookie("".$cookie_name."","",time()-$cookie_time);
}
*/
  /* Kill session variables */
$login = $_SESSION['lietotajvards']; 
  unset($_SESSION['lietotajvards']);
  unset($_SESSION['parole']);
  $_SESSION = array(); // reset session array
  session_destroy();   // destroy session.

mysql_query("UPDATE gamefarm_lietotaji SET laiks_kad_iegaja = '' WHERE lietotajvards = '$login'") or die(mysql_error());
echo "<meta http-equiv=refresh content='0;url=".$BASE."'>";
}

?>

un vēl config.php failā

 

	// ----------------- header ---------------- //

header('Cache-control: private'); // IE 6 FIX
// always modified
header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
// HTTP/1.1
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
// HTTP/1.0
header('Pragma: no-cache');

Edited by anonīms
Link to comment
Share on other sites

index.php failā 22 rinda ir

<link rel="shortcut icon" href="/design/favicon.jpg" type="image/jpg" />

bet nu pirms tam vēl ir

 

<?php
session_start();
$BASE = 'http://www.aaaa.lv';

 if(strtolower($_SERVER['HTTP_HOST'])!="www.aaaaa.lv"){
header("Location: http://www.aaaa.lv".$_SERVER['REQUEST_URI']);
exit;
 }



include "aaaaaaaaaaaaaaaa/function.php"; 
include "aaaaaaaaaaaaaaaa/language_switch.php";
include "aaaaaaaaaaaaaaaa/config.php";
include "aaaaaaaaaaaaaaaa/login.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Link to comment
Share on other sites

ok thx. likšu sākumā.

 

hmmm, kaut kas nav ar cookijiem pareizi..

 

uzspiežot iziet viņš neizlagojas, ja ir remember me

 

login.php

$remember = $_POST['remember'];

  if($remember == 1)
  {
setcookie ($cookie_name, 'lietotajvards='.$_POST['user'].'&parole='.$md5pass, time() + $cookie_time); // post ir aizsargats
  }

 

un logout.php

 

if(isset($_COOKIE[$cookie_name])){
setcookie("".$cookie_name."","lietotajvards=''&parole=''",time()-$cookie_time);
}

 

kur varētu būt vaina?

Edited by anonīms
Link to comment
Share on other sites

×
×
  • Create New...