Hopefully I'm posting this in the right place.
I'm trying to use session variables to keep track of a user's name when they log into my server. I keep getting this error:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent
Here's the code I'm trying to execute: (the error is thrown on line 6, where <?php session_start(); ?> is.)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="default2.css" type="text/css" rel="stylesheet" />
<?php session_start(); ?>
<title>Main Page</title>
</head>
<body>
<div id="main">
<div id="bannertop">
<?php
if ($_SESSION['myusername'] == NULL){
echo"<script Language='JavaScript' type='text/javascript' src='language_us.js'></script>
<script>assign_var();</SCRIPT>
<script language='JavaScript' src='nsutil.js'></script>
<script>
var next_page='login.html';
function start_redirect()
{
document.location.href = next_page;
}
setTimeout('start_redirect()',2500);
</script>";
session_destroy();
}
$username = $_SESSION['myusername'];
echo "<h1 id='banner'>Hello, ' .$username.'!</h1>";
?></div>
<div id="foreground">
<h3 id="toptitle">Your current logins:</h3>
<?php include("display_table2.php");?>
</div>
<center>
<input type="button" name="newlogin" value="New Login" onclick="window.location = 'insert.html' " />
<input type="button" name="deletelogin" value="Delete Login" onclick="window.location = '/delete_form.php'"/>
<span id="logoutbutton">
<input type="button" name="logout" value="Logout" onclick="window.location = '/logout.php'"/></span>
</center>
</div>
</body>
</html>
Can anybody see where I'm going wrong here?
Let me know if you need any further info.
thanks,
ED
