i have some problem, my codes is working normally, but the session is not. here the codes :
public function index()
{
if (isset($_POST['btnSubmit'])) {
$this->lm->username = $_POST['username'];
$this->lm->password = $_POST['password'];
$sql = sprintf("SELECT hakAkses, nip FROM user WHERE username = '%s' AND password = '%s'",
$this->lm->username,
$this->lm->password
);
$query = $this->db->query($sql);
$row = $query->row();
$sessData = array('nip' => $row->nip,
'hakAkses' => $row->hakAkses);
$this->session->set_userdata($sessData);
print_r($this->session->all_userdata());
if ($this->session->userdata('hakAkses') == 'ADMIN') {
redirect('Admin/index','refresh');
} else if ($this->session->userdata('hakAkses') == 'PENGAJAR'){
redirect('Pengajar/index','refresh');
} else {
redirect('Login','refresh');
}
} else {
$this->load->view('Login/LoginView');
}
}
That went well when i did it after set the session$this->session->set_userdata($sessData);
. But when i try print again in other form the session has gone.
my session config :
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_sessios';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
OK the reason is everytime i redirect page the session generate new session. how to handle this?