note 69418 added to ref.session
| From: | roan dot kattouw at home dot nl | Date: | Tue, 05 Sep 2006 18:07:33 +0000 |
| Subject: | note 69418 added to ref.session | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116714@lists.php.net to get a copy of this message | ||
I've just done a lot of debugging on a session that just wouldn't start, and finally found
the problem after an hour and a half:
<?php
require_once('config.php');
// ...
session_start();
// Rest of session stuff goes here
?>
config.php:
<?php
// config stuff goes here
?>
<-- BLANK LINE
That blank line was outputted to the browser. That's not a major problem, unless you call a
function that only works when nothing has been outputted to the browser yet. session_start() just
happens to be one of them.
So:
- Call session_start() first thing, preferably before any require()s or include()s.
- Never add a blank line after the ?> tag, as it might give others (or yourself) this kind of
headaches.
----
Server IP: 194.109.193.119
Probable Submitter: 217.121.124.23
----
Manual Page -- http://www.php.net/manual/en/ref.session.php
Edit -- https://master.php.net/note/edit/69418
Del: integrated -- https://master.php.net/note/delete/69418/integrated
Del: useless -- https://master.php.net/note/delete/69418/useless
Del: bad code -- https://master.php.net/note/delete/69418/bad+code
Del: spam -- https://master.php.net/note/delete/69418/spam
Del: non-english -- https://master.php.net/note/delete/69418/non-english
Del: in docs -- https://master.php.net/note/delete/69418/in+docs
Del: other reasons-- https://master.php.net/note/delete/69418
Reject -- https://master.php.net/note/reject/69418
Search -- https://master.php.net/manage/user-notes.php