Hi guys, i'm brazilian, and sorry about my english.
Ok, let's go to the problem:
I'm trying to make a logoff button, and when a user click in logoff, i call the function logoff:
function logoff(){
$this->session->sess_destroy();
$this->session->unset_userdata(array('user_id', 'user_nome', 'user_admin', 'user_logado'));
set_msg('logoff', 'Logoff efetuado com sucesso.', 'sucesso');
redirect('usuarios/login');
}
but, when i destroy the session, i can't create a new one to display the message that was set in 'set_msg' function.
I've two function in my helper to display it:
function set_msg($id = 'msgerro', $msg = NULL, $tipo = 'erro'){
$CI =& get_instance();
switch($tipo):
case 'erro':
$CI->cookies->set_flashdata($id, '<div class="alert-box alert radius">'.$msg.'</div>');
break;
case 'sucesso':
$CI->session->set_flashdata($id, '<div class="alert-box sucess radius">'.$msg.'</div>');
break;
default:
$CI->session->set_flashdata($id, '<div class="alert-box radius">'.$msg.'</div>');
break;
endswitch;
}
//Verifica se existe uma mensagem para exibir na tela atual.
function get_msg($id, $print = TRUE){
$CI =& get_instance();
$flash = $CI->session->flashdata($id);
THAT VALUE WAS COMING NULL BECAUSE OF SESSION DESTROY.
var_dump($flash);
if(isset($flash)){
if($print){
echo $flash;
return TRUE;
}
else{
return $CI->session->flashdata($id);
}
}
Make sense?
Someone have a hint to give me, how to fix this problem?
My CI version is 3.0.3
in old versions, people type $this->session->create(); and it's work very well..
Heelp me!