PHP - "Cannot send session cookie - headers already sen

Vladkata

Registered
Здравейте! Наскоро си взех хостинг, супер е! Та по темата - преди ползвах безплатен хостинг от 000 Webhost и нямаше грешки в сайта. Сега като го кача на хостинга, излиза следната грешка:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/site/index.php:7) in /home/site/index.php on line 43

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/site/index.php:7) in /home/site/index.phpp on line 43

Ред 43:
PHP:
session_start();

Не разбирам защо дава грешка. Сесията започва... Това на безплатния хостинг го няма, а на платения го има. Дали не е грешката в мен, ако трябва да направя нещо...

*Нищо не е променяно по сайта.

Благодаря предварително!
 
Идва следната грешка:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/site/index.php:7) in /home/site/index.php on line 44

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/site/index.php:7) in /home/site/index.php on line 44

Ред 44:
PHP:
session_start();
 
A session_start(); най-отгоре ли ти стои или има и нещо над него?
 
Всичко над реда със сесията:

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>заглавие</title>
<script type="text/javascript" src="tooltip.js"></script>
<script type="text/javascript" src="cufon.yui.js"></script>
<script type="text/javascript" src="font.js"></script>
<script type="text/javascript">
Cufon.replace('ul, div, h1');
</script>
</head>

<link rel="shortcut icon" href="favicon.png">

<body onload=init()>
<div id="a" style="background-image: url(tooltip.png); background-repeat: repeat-x; width: 315px; height: 150px; border: solid 1px #001a29; text-align: center; font-family: sans-serif; color: #fff; box-shadow: 2px 2px 10px #000; -moz-box-shadow: 2px 2px 10px #000; -webkit-box-shadow: 2px 2px 10px #000; outline-style: none; z-index:1000;"></div>
<script>
var t1=null;
var l1="текст";
function init()
{
 t1 = new ToolTip("a",false);
}
</script>
<?php
session_start();
 
PHP:
<?php
session_start(); 
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>заглавие</title>
<script type="text/javascript" src="tooltip.js"></script>
<script type="text/javascript" src="cufon.yui.js"></script>
<script type="text/javascript" src="font.js"></script>
<script type="text/javascript">
Cufon.replace('ul, div, h1');
</script>
</head>

<link rel="shortcut icon" href="favicon.png">

<body onload=init()>
<div id="a" style="background-image: url(tooltip.png); background-repeat: repeat-x; width: 315px; height: 150px; border: solid 1px #001a29; text-align: center; font-family: sans-serif; color: #fff; box-shadow: 2px 2px 10px #000; -moz-box-shadow: 2px 2px 10px #000; -webkit-box-shadow: 2px 2px 10px #000; outline-style: none; z-index:1000;"></div>
<script>
var t1=null;
var l1="текст";
function init()
{
 t1 = new ToolTip("a",false);
}
</script>

session_start(); трябва да е НАД ВСЯКАКАВ HTML.
 
Отново грешка:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/site/index.php:1) in /home/site/index.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/site/index.php:1) in /home/site/index.php on line 2

Ред 2:
PHP:
session_start();
 
PHP:
<?php
session_start();
ob_start(); 
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>заглавие</title>
<script type="text/javascript" src="tooltip.js"></script>
<script type="text/javascript" src="cufon.yui.js"></script>
<script type="text/javascript" src="font.js"></script>
<script type="text/javascript">
Cufon.replace('ul, div, h1');
</script>
</head>

<link rel="shortcut icon" href="favicon.png">

<body onload=init()>
<div id="a" style="background-image: url(tooltip.png); background-repeat: repeat-x; width: 315px; height: 150px; border: solid 1px #001a29; text-align: center; font-family: sans-serif; color: #fff; box-shadow: 2px 2px 10px #000; -moz-box-shadow: 2px 2px 10px #000; -webkit-box-shadow: 2px 2px 10px #000; outline-style: none; z-index:1000;"></div>
<script>
var t1=null;
var l1="текст";
function init()
{
 t1 = new ToolTip("a",false);
}
</script>
 
Пробвах с ob_start(); под и над сесията, но отново грешка:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/site/index.php:1) in home/site/index.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at home/site/index.php:1) in /home/site/index.php on line 3

Ред 3:
PHP:
session_start();
 
PHP:
<?php
@session_start();
@ob_start(); 
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>заглавие</title>
<script type="text/javascript" src="tooltip.js"></script>
<script type="text/javascript" src="cufon.yui.js"></script>
<script type="text/javascript" src="font.js"></script>
<script type="text/javascript">
Cufon.replace('ul, div, h1');
</script>
</head>

<link rel="shortcut icon" href="favicon.png">

<body onload=init()>
<div id="a" style="background-image: url(tooltip.png); background-repeat: repeat-x; width: 315px; height: 150px; border: solid 1px #001a29; text-align: center; font-family: sans-serif; color: #fff; box-shadow: 2px 2px 10px #000; -moz-box-shadow: 2px 2px 10px #000; -webkit-box-shadow: 2px 2px 10px #000; outline-style: none; z-index:1000;"></div>
<script>
var t1=null;
var l1="текст";
function init()
{
 t1 = new ToolTip("a",false);
}
</script>
 
Vladkata каза:
Това на безплатния хостинг го няма, а на платения го има. Дали не е грешката в мен, ако трябва да направя нещо...

Грешката не е в теб,а просто на безплатния хост са пуснали т.нар output buffering,които оправя този проблем,но забавя доста сайта,и за това го няма в платения хост.
 
Мне.

Енкодинга беше на UTF-8, смених го на UTF-8 без BOM и се оправи - затова забравих.

Благодаря на всички!
 
Vladkata каза:
Мне.

Енкодинга беше на UTF-8, смених го на UTF-8 без BOM и се оправи - затова забравих.

Благодаря на всички!

Както казваш ,че заради енкодинга е давало тази грешка ? Едва ли,просто явно по-бавно се е обновила страницата и заради това ти е давало пак грешка.
 
Мне. Заради това е 1000%. Защото при различния енкодинг добавя интервал ( ) и разваля кода. А страницата се обновява на стотната.
 

Back
Горе