session_start(), cannot send session cookie/cache limiter

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
lomme47
Forum Newbie
Posts: 2
Joined: Wed Mar 18, 2009 12:55 pm

session_start(), cannot send session cookie/cache limiter

Post by lomme47 »

Hi, after spending the whole day reading forums I still can't figure this out.
These are the error messages I get.

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at ####/httpd.www/test.php:1) in ####/httpd.www/test.php on line 1

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at ####/httpd.www/test.php:1) in ####/httpd.www/test.php on line 1

2 files:

index.html

Code: Select all

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sdfsdf</title>
</head>
<body>
 
<a href="test.php">test</a>
 
</body>
</html>
test.php

Code: Select all

<?php session_start();?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
I click the Test link and the error occurs.

There's no linebreak, space or any other character before the php-tag, I checked in dreamweaver, notepad and eclipse.
(I saved both files as UTF-8 in notepad and the charsets are set to UTF-8 as you can see in the code)

So I figured I had to save the files as UTF-8 without BOM. I used dreamweaver for this but that didn't help.
So now I'm out of options.

Any help would be appriciated.
Enlighten me please :D
atonalpanic
Forum Commoner
Posts: 29
Joined: Mon Mar 02, 2009 10:20 pm

Re: session_start(), cannot send session cookie/cache limiter

Post by atonalpanic »

This works for me just how you typed it. There is probably a micconfigured setting in your php.ini
I suggest you read http://us.php.net/manual/en/function.header.php under the 'Notes' section.
lomme47
Forum Newbie
Posts: 2
Joined: Wed Mar 18, 2009 12:55 pm

Re: session_start(), cannot send session cookie/cache limiter

Post by lomme47 »

Yeah I guess it's something like that. the site is at http://www.one.com and I'm still waiting for an answer from them. Any suggestions on what I should be looking for inside php.ini?
atonalpanic
Forum Commoner
Posts: 29
Joined: Mon Mar 02, 2009 10:20 pm

Re: session_start(), cannot send session cookie/cache limiter

Post by atonalpanic »

Try output buffering as a temporary solution. I'm not sure what can cause this right of the top of my head.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: session_start(), cannot send session cookie/cache limiter

Post by php_east »

they aren't exactly error mesages, they are just warnings. the host probably has another script going before you do. maybe for advert purposes.
Post Reply