[UPHPU] Session.Destroy
Saint Chaos
saintchaos at gmail.com
Tue Jul 10 14:11:50 MDT 2007
On 7/10/07, Justin Giboney <giboney at giboneydesigns.com> wrote:
>
> I started the session on previous pages
>
> Do you have to start a session on every page?
>
> Justin Giboney
>
>
>
> On Jul 10, 2007, at 1:48 PM, Saint Chaos wrote:
>
> > On 7/10/07, Justin Giboney <giboney at giboneydesigns.com> wrote:
> >>
> >> Sorry if I have been asking a lot of questions lately, but I have a
> >> rough draft website due next week.
> >>
> >> I have customers log in a shop through a session and I created a
> >> simple signout.php with this code
> >>
> >> <?php
> >> session_destroy();
> >>
> >> $page = 'index.php';
> >> header( 'Location: ' . $page );
> >> ?>
> >>
> >> put I get this error
> >>
> >> Warning: session_destroy() [function.session-destroy]: Trying to
> >> destroy uninitialized session in /Library/WebServer/local/new_site/
> >> signout.php on line 2
> >>
> >> Warning: Cannot modify header information - headers already sent by
> >> (output started at /Library/WebServer/local/new_site/signout.php:2)
> >> in /Library/WebServer/local/new_site/signout.php on line 5
> >>
> >> Justin Giboney
> >
> >
> >
> > You have to start the session before you can destroy it.
> >
> >
> > <?php
> > session_start();
> > session_destroy();
> >
> > $page = 'index.php';
> > header( 'Location: ' . $page );
> > ?>
Yes. session_start either creates a new session or continues an existing
session.
Unless the session is actually initialized session_destroy doesn't know
which session to destroy, resulting in the first error you are getting.
The second error you are getting is just the result of the first error being
printed as you can't send header information after something has already
been printed to the screen.
--
>From the ashes shall rise a new age. An age without rules, without laws and
without men.
More information about the UPHPU
mailing list