note 89989 added to function.session-start
| From: | LaurenceJ44 at Hotmail dot com | Date: | Wed, 01 Apr 2009 08:36:29 +0000 |
| Subject: | note 89989 added to function.session-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152683@lists.php.net to get a copy of this message | ||
I kept getting:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers
already sent (output started at myfile.php:2)
Only when I had uploaded my pages from my home development server to my hosted website. the same
page worked fine in development, so there must be a difference in the php setup, but since this is a
site that hosts many different clients web sites, I can't get them to change thier config.
After a little bit of research and trial and error, I found the cure was to move the line:
<?php session_start(); ?>
to be the very 1st line in any .php file.
orginally I had:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php session_start(); ?>
<html>
<head>
...etc
so I changed it to :
<?php session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
...etc
and all is well...
The clue is in the warning message, it ends :2) which means the session_start() call is not on line
1 of the file!
Hope this helps & good Luck
Loz
----
Server IP: 69.147.83.197
Probable Submitter: 58.107.147.130
----
Manual Page -- http://www.php.net/manual/en/function.session-start.php
Edit -- https://master.php.net/note/edit/89989
Del: integrated -- https://master.php.net/note/delete/89989/integrated
Del: useless -- https://master.php.net/note/delete/89989/useless
Del: bad code -- https://master.php.net/note/delete/89989/bad+code
Del: spam -- https://master.php.net/note/delete/89989/spam
Del: non-english -- https://master.php.net/note/delete/89989/non-english
Del: in docs -- https://master.php.net/note/delete/89989/in+docs
Del: other reasons-- https://master.php.net/note/delete/89989
Reject -- https://master.php.net/note/reject/89989
Search -- https://master.php.net/manage/user-notes.php