function checkToken() { $this->layout = 'ajax'; if ($this->request->data['ajax']) { echo json_encode(array('token' => $_SESSION['CSRFTOKEN'])); exit; } else { print "You are not authorized to do this operation."; exit; } }