RE: [PHP] php session on thttpd
| From: | Chris Shiflett | Date: | Fri, 28 Mar 2003 23:39:11 +0000 |
| Subject: | RE: [PHP] php session on thttpd | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141522@lists.php.net to get a copy of this message | ||
> Warning: session_start() [function.session-start]: Cannot send session
> cookie - headers already sent by (output started at /index.php:7) in
> /index.php on line 20
>
> Warning: session_start() [function.session-start]: Cannot send session
> cache limiter - headers already sent (output started at /index.php:7) in
> /index.php on line 20
You cannot use header() or anything that relies on it like session_start()
after you output any HTML. So, you need to either:
1. Do this stuff at the top of your script before any output (even whitespace).
2. Add <? ob_start() ?> to the very top of your script. This buffers the output
until the very end for you.
> Warning: Unknown(): Your script possibly relies on a session side-effect
> which existed until PHP 4.2.3. Please be advised that the session
> extension does not consider global variables as a source of data, unless
> register_globals is enabled. You can disable this functionality and this
> warning by setting session.bug_compat_42 or session.bug_compat_warn to
> off, respectively. in Unknown on line 0
>
> In my php.ini file, I have
> session.bug_compat_42=Off
> session.bug_compat_warn=Off
This is harder to explain, but you can use $_SESSION['blah'] to reference
session variables and avoid the warning. If there is a session variable named
blah that has been registered, the syntax $blah references a variable of the
same name in globals. The warning is just letting you know that you have
probably made a mistake, because when register_globals is off, these are not
the same. I would recommend always using the $_SESSION[] syntax, as it is a
good idea to leave register_globals off.
Hope that helps.
Chris
=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/