View Full Version : session information
rschoenbach
04-24-2007, 03:11 AM
if (isset($_GET['logout']) || $_GET['logout'] == True) {
session_destroy();
header('Location: index.php');
exit;
}
Gives me this error:
Warning: Cannot modify header information - headers already sent by (output started at D:\Website\golf\header.html:7) in D:\Website\golf\scorecard.php on line 16
The purpose of this script is to do a session logoff. what am I doing wrong? Thanks
CFMaBiSmAd
04-24-2007, 04:12 AM
This is not really anything to do with sessions. The header(...) redirect cannot send the header to the browser because your code has already sent content to the browser - output started at D:\Website\golf\header.html:7 (line number 7)
It would appear that you have probably included a header.html file that outputs your header content. Once you output content, you cannot send further headers.
There are two ways to correct this -
1) Fix the logic in your code so that you determine if the redirect should occur first, then only output content on that page if you are going to stay on that page.
For your existing code, if you send content to the browser, depending on what it is, that partial page will be rendered by the browser and then the redirect will occur. This will cause a partial page to be displayed and then a different page to be displayed. Your visitors will wonder what is going on, it won't look good, and it wastes your bandwidth.
2) Use output buffering to work around the problem.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.