{"action":"opened","issue":{"url":"https://api.github.com/repos/janhenkgerritsen/codeception-laravel5-sample/issues/2","labels_url":"https://api.github.com/repos/janhenkgerritsen/codeception-laravel5-sample/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/janhenkgerritsen/codeception-laravel5-sample/issues/2/comments","events_url":"https://api.github.com/repos/janhenkgerritsen/codeception-laravel5-sample/issues/2/events","html_url":"https://github.com/janhenkgerritsen/codeception-laravel5-sample/issues/2","id":59716661,"number":2,"title":"[Proposal] Grab and manipulate Laravel Session beofre start in examples.","user":{"login":"erickubenka","id":3993510,"avatar_url":"https://avatars.githubusercontent.com/u/3993510?v=3","gravatar_id":"","url":"https://api.github.com/users/erickubenka","html_url":"https://github.com/erickubenka","followers_url":"https://api.github.com/users/erickubenka/followers","following_url":"https://api.github.com/users/erickubenka/following{/other_user}","gists_url":"https://api.github.com/users/erickubenka/gists{/gist_id}","starred_url":"https://api.github.com/users/erickubenka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erickubenka/subscriptions","organizations_url":"https://api.github.com/users/erickubenka/orgs","repos_url":"https://api.github.com/users/erickubenka/repos","events_url":"https://api.github.com/users/erickubenka/events{/privacy}","received_events_url":"https://api.github.com/users/erickubenka/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-03T22:27:35Z","updated_at":"2015-03-03T22:27:35Z","closed_at":null,"body":"Hi @janhenkgerritsen,\r\n\r\nI love your sample package and Laravel5 Module for Codeception, but I got stuck while handling POST requests to an API, that expects JSOn formatted input.\r\n\r\nLike me, you just ran into the `TokenMismatchException` of Laravel, when sending `POST`requests to the routes.\r\nTo tackle this issue you added a simple `if`-statement in `VerifyCsrfToken`, to exclude all requests to '/api' from validating against the csrf token. \r\nhttps://github.com/janhenkgerritsen/codeception-laravel5-sample/blob/master/app/Http/Middleware/VerifyCsrfToken.php#L18-L20\r\n\r\nWhile your example app, is an example, this solution looks a little hack. \r\n\r\nThe cleaner way I suggest is, to manipulate the session of laravel inside the test.\r\n\r\n```php\r\n // tests\r\n    public function returnsTrueWhenValid(ApiTester $I)\r\n    {\r\n        // grab session of laravel and set a static token for testing.\r\n        $session = $I->grabService('session');\r\n        $session->put('_token', 'testing');\r\n\r\n        $parameters = [\r\n            'foo' => 'key'\r\n            'bar' => 'value\r\n        ];\r\n\r\n        // Add the X-CSRF-TOKEN Header with the current token (set above)\r\n        $I->haveHttpHeader('X-CSRF-TOKEN', csrf_token());\r\n        $I->sendPOST($this->endpoint, json_encode($parameters));\r\n\r\n        $I->canSeeResponseCodeIs(200);\r\n\r\n    }\r\n```\r\n\r\nMy proposal is, to add this implementation to your examples of requesting a non-reading route.\r\n\r\nOtherwise, is there another cleaner way to handle this? \r\n\r\nBest regards,\r\nEric"}}