I have been told when output something like echo/var_dump before header() or session_start, a warning will be shown like this "php Cannot send session cookie-headers already sent by".
But the following code works fine. It is strange! Who can tell me the reason? PHP version is 5.6.9
<?php
echo 'hello';
setcookie('a','a');
session_start();
$_SESSION['a'] = 'a';
header("location:test.php");
?>