These are my first 5 lines in my index.php:
<?php
session_start();
if (!isset($_SESSION['cart'])) $_SESSION['cart']='';
$page = $_GET['page'];
?>
and so on..
I’m looking at the sessions trough the firefox->firebug->firecookie plugin and a session is not created.(I am sure of it because the cart that worked yesterday doesnt work today.)
Any ideas why this might happen and how to fix it ?
I found this when enabling errors:
Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at /home/controll/public_html/metalkonsult.com/index.php:1) in /home/controll/public_html/metalkonsult.com/index.php on line 2
I explored further – something IS sent to the browser but I dont know where its coming from. I did a var_dump(headers_list()); on the first line and this is what I get:
array(2) { [0]=> string(23) "X-Powered-By: PHP/5.2.6" [1]=> string(23) "Content-type: text/html" }
How do I turn this off ? What’s sending it ?
I set session.auto_start = 1
in php.ini in the website folder
sessions work now..
dont know what caused the problems but problem is temporarily fixed
Something is being sent to the browser first which is causing the headers to be sent. Check your code to make sure that there isn’t even a single space before your PHP code.