{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/14879","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/14879/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/14879/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/14879/events","html_url":"https://github.com/laravel/framework/issues/14879","id":171897414,"number":14879,"title":"TokenMismatchException with database session driver","user":{"login":"Wistars","id":9122948,"avatar_url":"https://avatars.githubusercontent.com/u/9122948?v=3","gravatar_id":"","url":"https://api.github.com/users/Wistars","html_url":"https://github.com/Wistars","followers_url":"https://api.github.com/users/Wistars/followers","following_url":"https://api.github.com/users/Wistars/following{/other_user}","gists_url":"https://api.github.com/users/Wistars/gists{/gist_id}","starred_url":"https://api.github.com/users/Wistars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wistars/subscriptions","organizations_url":"https://api.github.com/users/Wistars/orgs","repos_url":"https://api.github.com/users/Wistars/repos","events_url":"https://api.github.com/users/Wistars/events{/privacy}","received_events_url":"https://api.github.com/users/Wistars/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-18T13:12:23Z","updated_at":"2016-08-26T12:51:52Z","closed_at":null,"body":"When I switch my session driver from file to database, it systematically throws a TokenMismatchException on login. This have been reported previously (see [Stackoverflow](http://stackoverflow.com/questions/38850002/laravel-tokenmismatchexception-after-changing-session-driverl) and [Laracast](https://laracasts.com/discuss/channels/laravel/tokenmismatchexception-when-session-driver-is-database) for example). The session works fine with the file driver but not with the database driver. I am using the sessions table from the migration. I noticed that the user_id is NULL in the session table. \r\n\r\n**config/session.php**\r\n```\r\n'driver' => env('SESSION_DRIVER', 'database'),\r\n'lifetime' => 120,\r\n'expire_on_close' => false,\r\n'connection' => \"mysql\",\r\n'lottery' => [2, 100],\r\n 'secure' => true,\r\n\r\n```\r\n\r\n**config/auth.php**\r\n```\r\n//I changed this to match the User namespace in my application\r\n'providers' => [\r\n        'users' => [\r\n            'driver' => 'eloquent',\r\n            'model' => App\\Models\\User::class,\r\n        ],\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/242726873","html_url":"https://github.com/laravel/framework/issues/14879#issuecomment-242726873","issue_url":"https://api.github.com/repos/laravel/framework/issues/14879","id":242726873,"user":{"login":"RodionMun","id":5294201,"avatar_url":"https://avatars.githubusercontent.com/u/5294201?v=3","gravatar_id":"","url":"https://api.github.com/users/RodionMun","html_url":"https://github.com/RodionMun","followers_url":"https://api.github.com/users/RodionMun/followers","following_url":"https://api.github.com/users/RodionMun/following{/other_user}","gists_url":"https://api.github.com/users/RodionMun/gists{/gist_id}","starred_url":"https://api.github.com/users/RodionMun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RodionMun/subscriptions","organizations_url":"https://api.github.com/users/RodionMun/orgs","repos_url":"https://api.github.com/users/RodionMun/repos","events_url":"https://api.github.com/users/RodionMun/events{/privacy}","received_events_url":"https://api.github.com/users/RodionMun/received_events","type":"User","site_admin":false},"created_at":"2016-08-26T12:51:52Z","updated_at":"2016-08-26T12:51:52Z","body":"Try set `user_id` in `sessions` table to nullable. It did trick for me."}}
{"actor":{"display_login":"RodionMun"}}