enuk

HTTP Headers


    <?php
        header("Access-Control-Allow-Origin: *");
        header("Content-Type: application/json; charset=UTF-8");
        header("Access-Control-Allow-Methods: POST");
        header("Access-Control-Max-Age: 3600");
        header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
    ?>
    

    <?php
        setcookie("TestCookie","SomeValue");
        header("X-Sample-Test: foo");
        header("Content-type: text/plain");
    ?>
    
    <html>
    <body>
    
    <?php
        var_dump(headers_list());
    ?>
    
    </body>
    </html>
    

    array(3) {
        [0]=>
        string(32) "Set-Cookie: TestCookie=SomeValue"
        [1]=>
        string(18) "X-Sample-Test: foo"
        [2]=>
        string(38) "Content-type: text/plain;charset=UTF-8"
    }