Login system with Codegniter

0

I have a problem with a login system that I have developed.

On my local machine it works 100%. But when I uploaded it to the server it is giving a session error, saying that an active session already exists. When I uploaded the system I went to test and it gave error.

Thesearethefilesthatlogin.

Userclass:

function__construct(){parent::__construct();$this->load->model('user_model');}publicfunctionlogin(){$this->load->view('admin/login');}functionvalidar(){$user=$this->input->post('user');$senha=$this->input->post('senha');if(empty($user)||empty($senha)){$this->session->set_flashdata("error", "Preencha todos os campos.");
        redirect(base_url('login'));
    }elseif ($senha <= 6) {
        $this->session->set_flashdata("error", "O campo senha deve conter mais que 6 caracteres.");
        redirect(base_url('login'));
    }else{
        $usuario = $this->user_model->loginUser($user, md5($senha));
        if ($usuario) {
            if($usuario['user_status']==1){
                $this->session->set_userdata('logged', true);
                $this->session->set_userdata('nome', $usuario['display_name']);
                $this->session->set_userdata('id', $usuario['ID']);
                redirect('admin/home');
            }else{
                $this->session->set_flashdata("error", "Este usuario não esta ativo.");
                redirect(base_url('login'));
            }
        }else{
            $this->session->set_flashdata("error", "Usuario ou senha incorretos");
            redirect(base_url('login'));
        }
    }
}

function logout(){
    $this->session->unset_userdata('logged');
    $this->session->unset_userdata('nome');
    $this->session->unset_userdata('id');
    redirect(base_url('login'));
}

Manager Class:

function __construct()
{
    parent::__construct();
    if ($this->session->userdata('logged')==false){
        redirect('login');
    }
}

public function principal(){
    $this->load->view('admin/home');
}

// view da lista dos post
public function post(){
    $this->load->view('admin/post');
}

// adicionar uma nova publicação
public function addPost(){
    $this->load->view('admin/posts/addPosts');
}

public function usuarios(){
    $this->load->view('admin/users/list-users');
}

public function newUsers(){
    $this->load->view('admin/users/new-user');
}

Just remembering that localhost works. When it goes on the web server this error happens.

    
asked by anonymous 23.09.2018 / 19:30

0 answers