Created
June 3, 2018 13:34
-
-
Save xiaoysh8/e20169994e632925b2f36be3ce6fdb67 to your computer and use it in GitHub Desktop.
laravel Remembering Users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Remembering Users | |
| If you would like to provide "remember me" functionality in your application, you may pass a boolean value as the second argument to the attempt method, which will keep the user authenticated indefinitely, or until they manually logout. Of course, your users table must include the string remember_token column, which will be used to store the "remember me" token. | |
| if (Auth::attempt(['email' => $email, 'password' => $password], $remember)) { | |
| // The user is being remembered... | |
| } | |
| If you are using the built-in LoginController that is shipped with Laravel, the proper logic to "remember" users is already implemented by the traits used by the controller. | |
| If you are "remembering" users, you may use the viaRemember method to determine if the user was authenticated using the "remember me" cookie: | |
| if (Auth::viaRemember()) { | |
| // | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment