4
votes

i have some Problems with session_start();

I know that nothing should be outputted before the session_start(); statement

But i can't find the Problem in my Script

index.php:

<?php session_start();
include('functions.php');
if(!is_logged_in(session_id())){
    include('form.php');
}else{
?>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
<?php
}
?>

But i always geh following Error:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\fertige_scan\index.php:1) in C:\xampp\htdocs\fertige_scan\index.php on line 1

I hope you can help me :)

3
maybe you have spaces or newlines after closing tag? try to delete "?>" - llamerr
actually you'd be looking for spaces before your opening tag, right? - Oliver
Yes no Spaces before the opening Tag and no Spaces after the Closing Tag... - Jings
I should say that everytime i refresh the page a absolute new session_id() is generated what absolutely is not normal... - Jings
Does it happen even without including the functions.php file? - Czechnology

3 Answers

5
votes

Make sure your file is saved as ANSI format not UTF-8 format.

7
votes

Make sure you save your file without BOM if saving them in UTF8

2
votes

Assuming you have removed any extra characters after <? and before ?>, and that session_start(); is the first statement, you can try to change the file encoding to ANSI or UTF-8 without BOM, as suggested in session_start's PHP documentation.