{"action":"created","issue":{"url":"https://api.github.com/repos/dingo/api/issues/874","repository_url":"https://api.github.com/repos/dingo/api","labels_url":"https://api.github.com/repos/dingo/api/issues/874/labels{/name}","comments_url":"https://api.github.com/repos/dingo/api/issues/874/comments","events_url":"https://api.github.com/repos/dingo/api/issues/874/events","html_url":"https://github.com/dingo/api/issues/874","id":139397165,"number":874,"title":"Session is saved twice","user":{"login":"Anahkiasen","id":1321596,"avatar_url":"https://avatars.githubusercontent.com/u/1321596?v=3","gravatar_id":"","url":"https://api.github.com/users/Anahkiasen","html_url":"https://github.com/Anahkiasen","followers_url":"https://api.github.com/users/Anahkiasen/followers","following_url":"https://api.github.com/users/Anahkiasen/following{/other_user}","gists_url":"https://api.github.com/users/Anahkiasen/gists{/gist_id}","starred_url":"https://api.github.com/users/Anahkiasen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Anahkiasen/subscriptions","organizations_url":"https://api.github.com/users/Anahkiasen/orgs","repos_url":"https://api.github.com/users/Anahkiasen/repos","events_url":"https://api.github.com/users/Anahkiasen/events{/privacy}","received_events_url":"https://api.github.com/users/Anahkiasen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-03-08T21:22:01Z","updated_at":"2016-03-10T03:31:47Z","closed_at":null,"body":"Not sure I understand what this code is originally meant to do but in `\\Dingo\\Api\\Http\\Middleware\\Request::terminate` this is done:\r\n\r\n```php\r\nforeach ($middlewares as $middleware) {\r\n            list($name, $parameters) = $this->parseMiddleware($middleware);\r\n\r\n            $instance = $this->app->make($name);\r\n\r\n            if (method_exists($instance, 'terminate')) {\r\n                $instance->terminate($request, $response);\r\n            }\r\n        }\r\n```\r\n\r\nThis causes all middlewares to be terminated a second time, it doesn't matter for most but it causes the `StartSession` middleware to save the session twice, _also_ aging flash data twice. Basically flash messages don't work anymore since they're aged twice before anything can happen."},"comment":{"url":"https://api.github.com/repos/dingo/api/issues/comments/194643868","html_url":"https://github.com/dingo/api/issues/874#issuecomment-194643868","issue_url":"https://api.github.com/repos/dingo/api/issues/874","id":194643868,"user":{"login":"jasonlewis","id":829059,"avatar_url":"https://avatars.githubusercontent.com/u/829059?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonlewis","html_url":"https://github.com/jasonlewis","followers_url":"https://api.github.com/users/jasonlewis/followers","following_url":"https://api.github.com/users/jasonlewis/following{/other_user}","gists_url":"https://api.github.com/users/jasonlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonlewis/subscriptions","organizations_url":"https://api.github.com/users/jasonlewis/orgs","repos_url":"https://api.github.com/users/jasonlewis/repos","events_url":"https://api.github.com/users/jasonlewis/events{/privacy}","received_events_url":"https://api.github.com/users/jasonlewis/received_events","type":"User","site_admin":false},"created_at":"2016-03-10T03:31:47Z","updated_at":"2016-03-10T03:31:47Z","body":"Are you doing anything else? When I hit an endpoint with it enabled I'm only seeing it terminated once. I threw a `\\Log::info('session terminated')` in the `StartSession.php` middleware, it's only logged once per request.\r\n\r\nI've also tried with internal requests. Seems to be working fine.\r\n\r\nSo any code you can provide to help replicate this would be great."}}