i made a simple logout url with the controller and it looks like this:
class Auth extends MX_Controller{
function logout(){
$this->session->sess_destroy();
$this->bootstrap->unsetUserCookie();
redirect(base_url(),'',301);
}
}
then
class Bootstrap{
function unsetUserCookie(){
$CI =& get_instance();
$CI->input->set_cookie(
array(
'name'=>'remember_me',
'value'=>'',
'expire'=>''
));
$CI->input->set_cookie(
array(
'name'=>'remember_me_n',
'value'=>'',
'expire'=>''
));
$CI->input->set_cookie(
array(
'name'=>'duser_lang',
'value'=>'',
'expire'=>''
));
$CI->input->set_cookie(
array(
'name'=>'duser_country',
'value'=>'',
'expire'=>''
));
}
}
i'm using the session DB these are the config params i'm using:
$config['sess_cookie_name'] = 'sess_id';
$config['sess_expiration'] = 0; //24hours -> 8640
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_session';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 3000000000;
then i created a simple session library and don't know if this can block anything but i guess no cause i receive no errors at all:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*We encode/decode all session data in base64 to avoid problems with multybityes data*/
class MY_Session extends CI_Session {
function set_userdata($data, $singleVar = NULL) {
if(is_array($data)){
$newValues = array();
foreach ($data as $key=>$value) {
$newValues[$key] = base64_encode($value);
}
parent::set_userdata($newValues);
}
else{
if(is_array($singleVar)){
$newValues = array();
foreach ($singleVar as $key=>$value) {
$newValues[$key] = base64_encode($value);
}
//Encode $singleVar
parent::set_userdata($data, $newValues);
}else{
parent::set_userdata($data, base64_encode($singleVar));
}
}
}
function set_flashdata($data, $singleVar = NULL) {
if(is_array($data)){
$newValues = array();
foreach ($data as $key=>$value) {
$newValues[$key] = base64_encode($value);
}
parent::set_flashdata($newValues);
}
else{
if(is_array($singleVar)){
$newValues = array();
foreach ($singleVar as $key=>$value) {
$newValues[$key] = base64_encode($value);
}
//Encode $singleVar
parent::set_flashdata($data, $newValues);
}else{
parent::set_flashdata($data, base64_encode($singleVar));
}
}
}
public function userdata($item) {
$data = parent::userdata($item);
if(is_array($data)){
$newData = array();
foreach ($data as $key => $value) {
$newData[$key] = base64_decode($value);
}
return $newData;
}else{
//Decode $data
return base64_decode($data);
}
}
}
/* End of file */
/* Location: ./application/controllers/ */
?>
the url is so simple,it just had to delete session and cookies, but the session and the cookies seems not to be deleted cause after launching the logout url i'm still logged.
Any clue please?