Session code

I have been trying to use sessions to store data. Its for use with a forum. It will store the username. I came up with the following warning error “session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /session1.php”

This is my code


<?php 
 
session_start();  
if(isset($_SESSION['views']))
    $_SESSION['views'] = $_SESSION
['views']+ 1;
else
    $_SESSION['views'] = 1;
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD 

XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xh

tml1-transitional.dtd">
<html>
<head>
</head>

<body>



<?php
echo "views = ". $_SESSION

['views']; 
?>


<a href="session2.php">link2</a>


</body>
</html>








Is there a blank line, a space, anything before that <?php tag? If so, there’s your error.

No problems with the code in the OP’s post when tested locally. hairybobby, you might have a BOM at the beginning of the file.