0

This is my code in Participate.php file:

<?php session_start();
$_SESSION['id'] = 'Apps';
?>
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
 ...
</body>
</html>

But it shows error:

Warning: PHP Startup: Cannot start session when headers already sent in /Participate.php on line 1

I checked for white spaces there are no any. session_start(); isn't invoking after header. Html section looks fine. File isn't included somewhere, is separated.

P. M.
  • 17
  • 9
  • Is this ALL the code in that file – RiggsFolly May 03 '19 at 12:55
  • 3
    Are you including this file in another script? – RiggsFolly May 03 '19 at 12:56
  • @RiggsFolly this is all code in that file except html code between and sections. This file is not included. – P. M. May 03 '19 at 12:57
  • View the source in the browser, and look for anything above that error message – aynber May 03 '19 at 12:57
  • @aynber what you mean above? There is no above. Complete error message is "Warning: PHP Startup: Cannot start session when headers already sent in /www.appsarchitect.pl/Participate.php on line 1" – P. M. May 03 '19 at 13:00
  • 1
    Just verify that the session is not started before starting it: `if (session_status() == PHP_SESSION_NONE) { session_start(); }` – Martin May 03 '19 at 13:05
  • @Martin same error showing – P. M. May 03 '19 at 13:13
  • Additionally [`session.auto_start`](https://www.php.net/manual/de/session.configuration.php#ini.session.auto-start) might need disabling in this case. – mario May 03 '19 at 13:32

1 Answers1

0

Most likely your file has a BOM which is not visible in your editor, but still, it's a content read by PHP and sent to the browser

Maxim Krizhanovsky
  • 26,265
  • 5
  • 59
  • 89