Jump to content

Yet another extremely simple problem...


Hangwire

Recommended Posts

Can someone explain to me whats wrong with this?

 

<?php
session_start();
// store session data
$_SESSION['views']=1;
?>


<html>
<body>

    <?php
    //retrieve session data
    echo "Pageviews=". $_SESSION['views'];
    ?>

</body>
</html> 

 

The output it gives me in the browser is this:

 

 

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at D:\Program Files\xampp\xampp\htdocs\sessions.php:1) in D:\Program Files\xampp\xampp\htdocs\sessions.php on line 2

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\Program Files\xampp\xampp\htdocs\sessions.php:1) in D:\Program Files\xampp\xampp\htdocs\sessions.php on line 2

Pageviews=1

 

Explanation?  :-[

 

Link to comment
https://forums.phpfreaks.com/topic/213249-yet-another-extremely-simple-problem/
Share on other sites

There's a sticky post for this commonly occurring problem - http://www.phpfreaks.com/forums/index.php/topic,37442.0.html

 

Based on the line number (1) where the output is occurring, you likely have a file saved as a UTF-8 file with the BOM characters. You would need to save the file without the BOM or save it as an ANSI file.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.