note 89989 deleted from function.session-start by peehaa
| From: | peehaa@php.net | Date: | Fri, 09 Dec 2016 22:15:32 +0000 |
| Subject: | note 89989 deleted from function.session-start by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208343@lists.php.net to get a copy of this message | ||
Note Submitter: LaurenceJ44 at Hotmail dot com
----
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