I try to check when someone logged in his/her account show the page with the session, I loaded session in libraries but the session doesn't work And Sorry For My Bad English Thanks For The Help :)
This Is The Model
class login_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
public function check()
{
$username = $this->input->post('username');
$password = $this->input->post('password');
$remember = $this->input->post('remember');
$this->db->select('username','password');
$this->db->from('user');
$this->db->where('username',$username);
$this->db->where('password',md5($password));
$result = $this->db->count_all_results();
if($result > 0)
{
$data_session = array(
'username'=>$username,
'islogin'=>true,
);
$this->session->set_userdata($data_session);
redirect('post/index');
}
This Is The Controller
class Post extends CI_Controller
{
public function index()
{
$login = $this->session->userdata('islogin');
if($login == true)
{
$data = array (
'name' => 'Hello',
);
$this->load->view('post/index',$data);
}
else {
redirect('login/index');
}
}
}
This Is The Config
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'weblogdata';
$config['sess_expiration'] = 3600;
$config['sess_save_path'] = 'tbl_ci_sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE;
$config['encryption_key'] = m.D~wt,wA:MjS9$]g<H4Z7eW.7`0vDbX$F`LUgCg+>$1?0L$vq1:7vaVf&d{U(