Created
January 8, 2013 01:53
-
-
Save jblac/4480401 to your computer and use it in GitHub Desktop.
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
<?php | |
class BM_Controller extends CI_Controller { | |
function __construct() { | |
parent::__construct(); | |
$logged = $this->check_login(); | |
$cArray = array('login', 'logout'); | |
$this->load->helper('url'); | |
if ($logged == 0 && !in_array($this->uri->segment(1), $cArray) && !in_array($this->uri->segment(2), $cArray)) { | |
redirect('/login'); | |
} | |
} | |
function check_login() { | |
$logged_in = 0; | |
$user = $this->session->userdata('user'); | |
if (isset($user)) { | |
if ($user['intime'] > time() - 3600) { | |
$user['intime'] = time(); | |
$this->session->set_userdata('user', $user); | |
$logged_in = 1; | |
} else { | |
$this->session->unset_userdata('user'); | |
$logged_in = 0; | |
} | |
} | |
return $logged_in; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment