Hi everyone, got really strange issue with a template I have started to build.

I am continually getting the follwing error message
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

Even though the only code I have on my page is

<?php
session_start();
?>
<!DOCTYPE html>
    <html>
    <head>

    </head>
    <body>


    </body>
</html>

it's driving me crazy... Any help would be appreciated, thanks

It a template, for what?
It probley means that it is an included file.

Please, please, please do not reply with the "have you removed all white spaces"
you session start must be before any other code and any other html.
I have been through google god knows how many times & searched through DaniWeb for the last few hours before posting my question.

The code added to this thread is the same code generating the error.

@pzuurveen -
No this is the index.php file it is not a template file that requires including, if that were the case it would be

    require_once '../_inc/file.php';
    include_once '../_inc/file.php';

For the error:

Warning: session_start(): Cannot send session cache limiter - headers already sent ...

this kind of errors would occur, when the encoding of your script file needs to send some headers just after your script starts to execute,

this happens mostly with the scripts using normal utf8 encoding. (refer http://php.net/manual/en/function.session-start.php for more info)

So only solution is to write the code in notepad instead of any other editor as it might add some characters like space before session_start()(Read http://board.phpbuilder.com/showthread.php?10310794-RESOLVED-Warning-session_start()-Cannot-send-session-cookie-headers-already-sent).Read last 3 comments.

So that's the one and only file there is? What happens if you just type

<?php session_start(); ?>

in an empty PHP file and open that? Are you sure it's not your installation that's sending its own header? Are you using XAMPP or something else?

Hi @minitauros

This is the first file in a new website I am building,
I have a number of websites on the same hosting account that work without any problems,
It's driving me fecking crazy :)

I have just done what you said, by placing just the <?php session_start(); ?> at the top of the file, and it still gives me the same error...

Seriously head scratching now.... HELP.....

Well I guess you should call your web service provider and tell them to stop fucking around and fix this shit :D

Add this above session_start()

ob_start();

That could indeed work but it's crazy that if session_start() is your first line, it generates errors like this, right? I would certainly call my hosting provider :).

@minitauros -
I have uploaded different files to different domains from the same hosting account and I dont get any error...

@code_rum -
I have tried that mate thanks, Also putting the ob_flush at the end of the file as I had this problem with a different website I was working on. That was the first thing I tried...

Confused.com

Yes that is why I say, just pick up the phone and call your hosting provider ^^. If you can't fix it, they should be able to.

@minitauros -
I there anything I can look into, maybe in the ini file ? Are there settings I can change?

Open Your script into notepad++ (because there's a menu on notepad++ called encoding)
and convert encoding of your script to 'Encode in UTF-8 without BOM'

Hm I don't think there is. It's weird anyway that you're having problems with only

session_start();

in a file. You could try, as code_rum suggests, opening your files in another editor, to see if anything can be detected. Notepad++ also has an option "Show all characters" (including hidden), under View-->Show Symbol-->Show all characters. That should make sure there are no weird, unwanted characters above your session_start() line. For the rest, I have no idea, I'm sorry!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.