3 The auth module provides methods to help you log users in and out of your application.
7 The [Auth::login] method handles the login.
10 // Handled from a form with inputs with names email / password
11 $post = $this->request->post();
12 $success = Auth::instance()->login($post['email'], $post['password']);
16 // Login successful, send to app
20 // Login failed, send back to form with error message
26 There are two ways to check if a user is logged in. If you just need to check if the user is logged in use [Auth::logged_in].
29 if (Auth::instance()->logged_in())
31 // User is logged in, continue on
35 // User isn't logged in, redirect to the login form.
39 You can also get the logged in user object by using [Auth::get_user]. If the user is null, then no user was found.
42 $user = Auth::instance()->get_user();
44 // Check for a user (NULL if not user is found)
47 // User is found, continue on
51 // User was not found, redirect to the login form
57 The [Auth::logout] method will take care of logging out a user.
60 Auth::instance()->logout();
61 // Redirect the user back to login page