0

So I've done quite a bit of digging and can only seem to come up with information on SlimFramework 2, nothing so much on 3.

My issue is this:

return $res->withStatus(401)->withHeader('Content-type','application/json')->write(json_encode(array(
            'Error'=>'Your session has timed out.',
            'X-SessionToken' => $session_uuid,
            'Server date/time' => date('c'),
            'Last activity' => Session::sharedInstance()->last_activity(),
            'Path' => $path
        )));

still returns back a status of 200, with the Content-type still set to text/html, but all of my body is there. Any thoughts? I tried looking through PSR-7 documentation on the write() to see if perhaps after that it sets the headers and status back to default, but didn't see anything.

Browser screen shot.

alexw
  • 8,468
  • 6
  • 54
  • 86

1 Answers1

0

So after doing some more looking and debugging I found that it wasn't setting the headers because it only sets them if !headers_sent(), which was coming back as false. That meant that I had additional output somewhere. Turned out at the very bottom of my PHP file that all of my code was in I had an extra line after my closing ?>. Such an amateur mistake.