take a look at the code below:
?><!DOCTYPE html><html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/admingeneral.css"/> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" ></script> <script type="text/javascript" src="js/js-code.js"></script> </head> <?phptry{ if(isset($_COOKIE['cookiename'])) { $cookievalue=$_COOKIE['cookiename']; redirect($cookievalue); } if(isset($_POST['submit'])&&(!empty($_POST['remember']))) { $username = $_POST['username']; $passwd = $_POST['password']; if ((login($username, $passwd))) { setcookie_pers($username); header("Location: adminmember.php"); } } require 'output_functions_admin.php';
This code above, normally, when run by the browser, it should output the "headers already sent" error and that is becausethe head section is before the setting of the cookie(the setcookie_pers functions sets a cookie). The problem is that sometimes I do not get an error, as I should-other times I get it.The behavior is unstable and I do not understand why. I wonder if there is something in browser behavior I miss here.