I am using Laravel 4.2 and I want to let users decide if they want their login to be remembered on their PC or not. So my login form looks like this:
When you tick the checkbox, the post fields will have 'remember_me' => 'on'
. The form posts to a named route called sessions.store
which is handled like so:
public function store()
{
// Capture input data
$input = Input::only('email', 'password');
// Validate input
$this->loginForm->validate($input);
// Login user
if (Auth::attempt($input, (Input::get('remember_me') == 'on')))
return Redirect::intended('/');
// Login error
return Redirect::back()->withInput()->withFlashError('Invalid portal account credentials provided');
}
For some reason, laravel keeps the user logged in (i.e. you close the browser completly and re-open it and you don't have to login, you are already logged in), even if they have not ticked the checkbox.
Any idea why this might be?
Update
This is my sessions/create.blade.php: http://pastebin.com/raw.php?i=MbrLgg6Y
This is my javascript checkbox helper: http://pastebin.com/raw.php?i=R8mNrj3s