im having a really weird issue with CodeIgniter 3, the main issue is that logged_in is not being passed, its always empty and when it gets to dashboard.php its always empty and it is redirected to the login page again, doesnt matter if the user/pass is correct, logged_in is always false because it is never set
this is the authenticate class:
PHP Code:
<?php class Authenticate extends MY_Controller{ public function login(){ $this->form_validation->set_rules('username','Username','trim|required|min_length[4]|xss_clean'); $this->form_validation->set_rules('password','Password','trim|required|min_length[4]|xss_clean'); if ($this->form_validation->run() == FALSE) { //Load View // echo CI_VERSION ; $this->load->view('admin/layouts/login'); } else { //Get From Post $username = $this->input->post('username'); $password = $this->input->post('password');
if($user_id){// $user_data = array( 'user_id' => $user_id, 'username' => $username, 'logged_in' => true ); //Set session userdata // This is where its not working, logged_in is not passed at all, // so $this->session->set_userdata($user_data);
//Set message $this->session->set_flashdata('pass_login', 'You are now logged in'); redirect('admin/dashboard'); }
<?php class Dashboard extends MY_Controller{ public function __construct(){ parent::__construct();
//Access Control // logged_in is always empty and is never passed so its always redirected to the // admin login page, doesnt matter if the user/pass is correct if(!$this->session->userdata('logged_in')){ redirect('admin/login'); } }
public function index(){ //Get Articles $data['articles'] = $this->Article_model->get_articles('id','DESC',10);