Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Auth extends CI_Controller {
- function __construct()
- {
- parent::__construct();
- }
- function index()
- {
- }
- function login()
- {
- $this->load->model('auth_model');
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- if ($this->auth_model->validate_login($username, $password))
- {
- // login success
- $userinfo = $this->auth_model->get_info($username);
- print_r($userinfo);
- $this->session->set_userdata('logged_in', TRUE);
- if ($this->auth_model->validate_admin($username))
- {
- $this->session->set_userdata('is_admin', TRUE);
- }
- else
- {
- $this->session->set_userdata('is_admin', FALSE);
- }
- $session_id = $this->session->userdata('session_id');
- if ($this->session->userdata('logged_in'))
- {
- echo 'Logged in!';
- echo "<br>";
- echo $session_id;
- }
- }
- else
- {
- // login failed
- echo 'Login failed';
- }
- }
- function logout()
- {
- $this->session->sess_destroy();
- redirect('home');
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement