RE: [PHP-DB] Sessions problems
| From: | Ford, Mike [LSS] | Date: | Mon, 06 Jan 2003 13:13:48 +0000 |
| Subject: | RE: [PHP-DB] Sessions problems | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-24584@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Sabina Alejandr Schneider [mailto:sabinaschneider@tutopia.com]
> Sent: 05 January 2003 20:17
>
> Hello everybody!!!!
> I was trying to use Sessions, but I had some problems.
>
> I have an old version of the Apache, that comes with the
> Red Hat 7.2.
>
> when executing this in my page:
>
> session_start();
> if(!isset($_SESSION['s_test'])){
> $_SESSION['s_prueba']=1;
> }
>
> There appear this in the page:
> Warning: Cannot send session cookie - headers already sent
> by (output started at /var/www/html/prueba/index.php:8) in
> /var/www/html/prueba/index.php on line 10
Well, the error message really says it all, it's just worded a bit opaquely! Basically,
setting a cookie uses an HTTP header, and all HTTP headers have to be sent before your actual page
content -- and the error message is saying that you can't send an HTTP header at line 10 of
your script, because you started outputting your page content at line 8.
> Warning: Cannot send session cache limiter - headers
> already sent (output started at
> /var/www/html/prueba/index.php:8) in
> /var/www/html/prueba/index.php on line 10
Same thing, but for a cache limiter header.
You need to re-order your script so that the header requests come before the start of real output.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211