[eluser]bhenbe[/eluser]
Hi all,
i have a little frustrating problem since two days... I had a disconnect button to my website and it don't works.
All is in the same controller : myaccount.
For each load, some global view are called. Account-box is a view with the "hello" and somes account infos...
Code:
class Myaccount extends CI_Controller {
private $datas = array();
public function __construct() {
parent::__construct();
$datas = array();
/*** session ***/
$datas['account'] = $this->active_session->get_account($this->session->userdata('id'));
/*** end session ***/
/*** start global views ***/
$this->datas['top_view'] = $this->load->view('global/top', $datas, true);
$this->datas['top_menu_view'] = $this->load->view('global/top-menu', $datas, true);
$this->datas['account_box_view'] = $this->load->view('global/account-box', $datas, true);
$this->datas['footer_view'] = $this->load->view('global/footer', $datas, true);
/*** end global views ***/
}
Here's the librarie Active_session called in the previous code :
Code:
public function get_account($user_id = false) {
$CI =& get_instance();
if ($user_id == false)
return false;
$CI->load->model('account_model');
$return = $CI->account_model->get_by_id($user_id);
if ($return == false)
return false;
$return['notification_count'] = $this->get_notification_count($user_id);
$return['notifications'] = $this->get_notifications($user_id);
return $return;
}
The open session code (redirect to the homepage if ok) :
Code:
public function identify() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="form-error">', '</div>');
$this->form_validation->set_rules('account-email', 'Adresse e-mail', 'trim|required|valid_email|callback_mail_exists|xss_clean');
$this->form_validation->set_rules('account-password', 'Mot de passe', 'trim|required|min_length[6]|max_length[20]|alpha_num|callback_password_exists|xss_clean');
if ($this->input->post('check-form') == 'true') {
if ($this->form_validation->run() == true) {
$this->load->model('account_model');
try {
$account = $this->account_model->get_by_email($this->input->post('account-email'));
$this->session->set_userdata('id', $account['id']);
$this->session->set_userdata('rank', $account['rank']);
redirect('', 'refresh');
return;
} catch (Exception $e) {
$this->load->library('custom_errors');
$this->custom_errors->set_error($e);
return;
}
}
}
$this->load->view('myaccount/identify', $this->datas);
}
The close session code :
Code:
public function disconnect() {
$this->session->unset_userdata('id');
$this->session->unset_userdata('rank');
$this->session->sess_destroy();
redirect('', 'refresh');
return;
}
And, another thing perhaps usefull... I write my code in english but the url's must be in french. So, i have some routes :
Code:
$route['mon-compte/identifier'] = 'myaccount/identify';
$route['mon-compte/deconnecter'] = 'myaccount/disconnect';
The disconnect function don't seems to work... Thanks for your help and sorry for my english.