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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.