public static function delete($id) { session_start(); $headers = apache_request_headers(); $token = $headers['X-Auth-Token']; if (!$headers['X-Auth-Token']) { header('Invalid CSRF Token', true, 401); return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT); } else { if ($token != $_SESSION['form_token']) { header('Invalid CSRF Token', true, 401); return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT); } else { Courses::delete($id); } } }