When accessing pages on my website (located at namcocentral.com), often the following error messages come up.
Warning: Cannot modify header information - headers already sent by (output started at /home/namcocen/public_html/template.php:7) in /home/namcocen/public_html/forum/includes/sessions.php on line 366
Warning: Cannot modify header information - headers already sent by (output started at /home/namcocen/public_html/template.php:7) in /home/namcocen/public_html/forum/includes/sessions.php on line 367
I'm not sure what is causing these error messages.
Although it says line 7 of template.php is causing the error, I don't see how that could be the cause, when that is merely a line importing a CSS file.
<style type="text/css">@import url('global.css');</style>
I think the following lines of template.php may be the problem...
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
// Start session management
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
?>
<div class="menuItem">
<h2>Login Box</h2>
<?php
if( !$userdata['session_logged_in'] ) // Is the user NOT logged in?
{
?>
You are not logged in. If you would like to login, input your login details below.<br />
<form action="forum/login.php" method="post" name="login">
<input type="text" name="username" size=12><br />
<input type="password" name="password" size=12><br />
Auto logon <INPUT class=text type=checkbox name=autologin>
<input type="hidden" name="redirect" value="../index.php"> <!-- Redirect the user to a page different than the PHPBB2 index page. You can delete this if you want. The path must be relative from the PHPBB2 login file. -->
<input type="submit" value="login" name="login">
</form>
<?php
}
?>
<?php
if( $userdata['session_logged_in'] ) // Is the user logged in?
{
$appendLogout = $u_login_logout = $phpbb_root_path.'login.'.$phpEx.'?logout=true&sid=' . $userdata['session_id']; // Add the session ID to the logout link
echo "Welcome back, <a href=\"forum/profile.php?mode=viewprofile&u=".$userdata['user_id']."\" title=\"".$userdata['username']."\">".$userdata['username']."</a><br />You have <a href=\"forum/privmsg.php?folder=inbox\" title=\"You have ".$userdata['user_unread_privmsg']." new messages\">".$userdata['user_unread_privmsg']." new private messages</a><br />";
echo "- <a href=\"forum/index.php\">Forum</a><br />";
echo "- <a href=\"forum/profile.php?mode=editprofile\" title=\"My Profile\">User CP</a><br />";
echo "- <a href=\"".$appendLogout."\" title=\"Logout\">Logout</a><br />";
} // end if, if you want you could add a login form in an else statement below
?>
</div>
The above code (obtained from a tutorial website), basically links my website to my phpBB forum, ensuring that people logged into the forum remain logged in, even when viewing the website. It also allows people to login, logout etc.
The other file mentioned in the errors is sessions.php. However, this is a standard phpBB file. As such, I know for a fact the code works. But, if it'll help, lines 366 and 367 are as follows:
setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);
Does anyone have any ideas about how to get rid of this error, or at least how the error has been caused? Thanks.