RE: [PHP] Validation and session variables
| From: | Graham Cossey | Date: | Wed, 27 Oct 2004 18:32:46 +0000 |
| Subject: | RE: [PHP] Validation and session variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-200465@lists.php.net to get a copy of this message | ||
> --- Chris Shiflett <shiflett@php.net> wrote:
>
> > On each page, it might be good to add some debugging
> > information near the
> > top (where session_start() is):
> >
> > <?php
> > session_start();
> > echo '<pre>' . htmlentities(print_r($_COOKIE, true))
> > . '</pre>';
> > echo '<pre>' . htmlentities(print_r($_GET, true)) .
> > '</pre>';
> > echo session_id();
> > ...
> >
> I added this in , on top, right under session_start()
> as shown and get this error:
>
> Warning: Cannot modify header information - headers
> already sent by (output started at
> /home/lurkkcom/public_html/page1.php:6) in
> /home/lurkkcom/public_html/page1.php on line 54
>
> So it's clashing with the redirect:
>
> Header ('Location:
> http://www.mysite.com/page2.php?'.SID);
>
If your script outputs anything and then tries to redirect it WILL throw
that error. I believe if you want to do echos AND redirects you'll have to
use output buffering (see the manual: http://uk.php.net/outcontrol) and only
output the buffer if you do not redirect.
HTH
Graham