public function submitQuiz($data) { 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, '1msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT); die; } 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); die; } else { // print_r(json_encode($data)); Quiz::submitQuiz($data); } } }