Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 17th, 2005, 12:28 PM
Nabeelah Ali
Guest
 
Posts: n/a
Default Help! Session error -- headers already sent...

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!

  #2  
Old July 17th, 2005, 12:28 PM
Kieren
Guest
 
Posts: n/a
Default 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]
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles