Laravel 4 如何使用laravel auth创建“记住我”操作
我的登录表单中有一个复选框,当选中时会记住用户。我正在使用以下代码,但它不适用于我: 视图:Laravel 4 如何使用laravel auth创建“记住我”操作,laravel-4,Laravel 4,我的登录表单中有一个复选框,当选中时会记住用户。我正在使用以下代码,但它不适用于我: 视图: @extends('layouts.main') @section('title') Dashboard @stop @section('content') {{ Form::open(array('url'=>'users/signin', 'class'=>'form-signin')) }} <h2 class="form-signin-heading">Pl
@extends('layouts.main')
@section('title') Dashboard
@stop
@section('content')
{{ Form::open(array('url'=>'users/signin', 'class'=>'form-signin')) }}
<h2 class="form-signin-heading">Please Login</h2>
{{ Form::text('email', null, array('class'=>'input-block-level', 'placeholder'=>'Email Address')) }}
{{ Form::password('password', array('class'=>'input-block-level', 'placeholder'=>'Password')) }}
{{ Form::checkbox('remember_me','false',false,array('class'=>'input-block-level')) }}
{{ Form::submit('Login', array('class'=>'btn btn-large btn-primary btn-block'))}}
{{ Form::close() }}
@stop
请帮我解决这个问题,这个功能不记得用户。
如果你有更好的代码,请告诉我。
谢谢 如果要记住用户,请传递第三个参数true 您的代码:
使用您上面编写的代码登录时出错:SQLSTATE[42S22]:未找到列:1054 where子句中的未知列“0”SQL:select*from users where=?和活动=?和0=?限制1绑定:数组0=>'vikas@sohyper.com,1=>1,2=>true,
public function postSignin() {
if (Auth::attempt(array('email'=>Input::get('email'), 'password'=>Input::get('password'),'active' => 1),Input::has('remember_me'))) {
return Redirect::to('users/dashboard')->with('message', 'You are now logged in!');
} else {
return Redirect::to('users/login')
->with('message', 'Your username/password combination was incorrect')
->withInput();
}
}
if (Auth::attempt(array('email' => $email, 'password' => $password), true))
{
// The user is being remembered...
}
public function postSignin() {
$rememberMe = false;
if(Input::has('remember_me')) {
$rememberMe = true;
}
if (Auth::attempt(array('email'=> Input::get('email'), 'password'=> Input::get('password') ), $rememberMe )) {
return Redirect::to('users/dashboard')->with('message', 'You are now logged in!');
} else {
return Redirect::to('users/login')
->with('message', 'Your username/password combination was incorrect')
->withInput();
}
}