The error is most likely occurring because the remember_token
field is required by the Auth
to be present in the users
table. So you should add a remember_token
field (likely a string field) in your users
migration table and migrate it. Then, you should create a user, log in the user and then try logging out. Hopefully, doing this will solve your problem.
Auth::logout() on missing remember_token database field
Question
I was simply trying to log out admin user from the Dashboard while I used this code for doing it:
Routes.php
Route::get('logout',array('uses'=>'AuthController@LogOut'));
AuthController.php
class AuthController extends Controller{
public function LogOut(){
Auth::logout();
return Redirect::to('login');
}
}
while it is giving me such error for log out
as i don't have such field in Database, and also it is not added to Database while Migration also.
Solution
OTHER TIPS
I guess you've run an update with composer recently and have upgraded the Laravel core. You'll need to perform a few steps to upgrade to the newest Laravel version as documented in the Laravel upgrade info here: http://laravel.com/docs/upgrade#upgrade-4.1.26
Laravel 4.1.26 introduces security improvements for "remember me" cookies...change requires the addition of a new remember_token column to your users (or equivalent) database table.
You'll also need to update your User
class with these methods if you're using Eloquent:
public function getRememberToken()
{
return $this->remember_token;
}
public function setRememberToken($value)
{
$this->remember_token = $value;
}
public function getRememberTokenName()
{
return 'remember_token';
}