note 56774 added to function.session-start
| From: | cmvondoom at hotmail dot com | Date: | Wed, 14 Sep 2005 23:01:59 +0000 |
| Subject: | note 56774 added to function.session-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-95190@lists.php.net to get a copy of this message | ||
hi ppl
I had a problem with sessions and headers not sent and spent some time knocking my head on the
computer trying to find the solution.
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started
at /home/canna/public_html/sites/default/settings.php:130) in
/home/canna/public_html/includes/session.inc on line 10
warning: Cannot modify header information - headers already sent by (output started at
/home/canna/public_html/sites/default/settings.php:130) in
/home/canna/public_html/includes/common.inc on line 99.
I think it's a common problem as i have seen many topics on the subject but none solved my
problem.
If you get this error put the code with the session_start() fucntion call in the beginning of the
web page code. even before any html tag. It solved my problem
example
<?php
session_id('123');
session_start();
if(!isset($_SESSION['nome']))
{
echo "<script> location='../index.php';</script>";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<? echo $_SESSION['nome'];?>
</body>
</html>
I hope it helps you out ppl
----
Manual Page -- http://www.php.net/manual/en/function.session-start.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56774
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56774&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56774&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56774&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56774&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56774&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56774&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56774&report=yes
Search -- http://master.php.net/manage/user-notes.php