Problem Cannot send session cache limiter - headers already

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Lobsterbob
Forum Newbie
Posts: 1
Joined: Sun Feb 07, 2010 2:49 am

Problem Cannot send session cache limiter - headers already

Post by Lobsterbob »

Hello everyone,
I am pretty new to PHP and need some help. I hope someone has the anwser for me. Its driving me nuts. :banghead: I am building a login form and get this error message:


Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/home/brietjens3/domains/finnianlegal.nl/public_html/login2.php:5) in /usr/home/brietjens3/domains/finnianlegal.nl/public_html/login2.php on line 6

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/brietjens3/domains/finnianlegal.nl/public_html/login2.php:5) in /usr/home/brietjens3/domains/finnianlegal.nl/public_html/login2.php on line 8


I did some research and found that often the problem is that there is something that is sent to the browser before the session starts. So I deleted all extra space, lines, echos, prints, but it was still giving me this problem. To identify the problem I have completely stripped my scripped to just the HTML basic tags and the sessiop, and it is still giving the same error. :crazy: This is what the code looks like:

Code: Select all

<html>
<head>
</head>
<body>
<?php 
session_start();
$_SESSION['name'] = "bob";
header("Location: admin.php");
?>
</body>
</html>
The file is encoded: UTF-8 without BOM

Someone please help! Thanks in advance. (english is not my first language, so my apologies for any mistakes unclearities)

Greetings from Amsterdam,
Bob

User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Re: Problem Cannot send session cache limiter - headers already

Post by Luke »

The HTML tags you are outputting before the header are your problem. Not sure what you think "output" is, but it is ANYTHING that is sent to the browser.

Also, when posting code in the forums, please use

Code: Select all

code blocks. I have edited your post to reflect how we'd like to see it posted in the future. Thanks
Post Reply