> i have a simple snippet of code :
But before you got to this code, there was some more code, or some includes,
or some HTML...
> <?
> session_start();
> $a = 10;
> session_register("a");
> ?>
>
> i am trying to understand how do session work.
>
> Accessing at this document directly from the server (it is a SuSE 7.2 PE -
> running PHP 4.0.4
> and apache 1.3.9) i find out the following problem:
>
> Warning: cannot send session cookie - headers already sent (output started
> at ....)
>
> and
>
> Warning: cannot send session cache limiter - headers already sent (output
> started at ....)
Sessions work by sending Cookies.
Cookies work by being transmitted as "Headers"
Headers are called headers because they come *BEFORE* any HTML.
Example:
--------------- What your browser *REALLY* sees: ---------------
Content-type: text/html
X-Powered-By: PHP-4.0.6
Content-length: 42
<HTML>
<more html in here>
</HTML>
----------------------------------------------------------------
That blank line in there is *CRITICAL*. Everything before that line is a
header. Everything after that line is HTML, and *NOT* a header.
Once your script has sent out some HTML, or even a blank line, PHP can't
suck them back in and send out a header.
Common Causes:
A trailing "newline" at the end of your "include" files. Get rid of them.
Adding your session code after your HTML and HEAD sections. Don't.
The session stuff and any header() or setcookie() calls *MUST* come first.
Another option is to turn on "Output Buffering" It will slow down stuff,
because PHP will basically store all your output until it's complete, and
then only send it at the end. But then it can stick headers in at any time
you like.
--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]