Connecting Tech Pros Worldwide Help | Site Map

Help! Session error -- headers already sent...

Nabeelah Ali
Guest
 
Posts: n/a
#1: Jul 17 '05
session_start()
session_destroy();
echo "<center><font color=red>You are now logged
out!</strong></font></center><br />";
header("Location: index.php");

Can somebody tell me why this bit of code in my logout script doesn't
work? what it's supposed to do is destroy the current session and then
redirect to the home page, but it says that 'Headers already sent' when
i try to do the redirect [header("location: index.php");].

Thanks in advance!

Kieren
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Help! Session error -- headers already sent...


You cannot use headers after you print (echo) anything (including
errors produced by your script).

You need:
session_start()
session_destroy();
header("Location: index.php");
echo "<center><font color=red>You are now logged
out!</font></center><br />";


"Nabeelah Ali" <nabeelah@gmail.com> wrote in message news:<1108215433.809662.158650@o13g2000cwo.googleg roups.com>...[color=blue]
> session_start()
> session_destroy();
> echo "<center><font color=red>You are now logged
> out!</strong></font></center><br />";
> header("Location: index.php");
>
> Can somebody tell me why this bit of code in my logout script doesn't
> work? what it's supposed to do is destroy the current session and then
> redirect to the home page, but it says that 'Headers already sent' when
> i try to do the redirect [header("location: index.php");].
>
> Thanks in advance![/color]
Closed Thread