Welcome Guest, Not a member yet? Register   Sign In
Session destroing flashdata

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->unset_userdata(array('user_id', 'user_nome', 'user_admin', 'user_logado'));
        set_msg('logoff', 'Logoff efetuado com sucesso.', 'sucesso');

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();
        case 'erro':
            $CI->cookies->set_flashdata($id, '<div class="alert-box alert radius">'.$msg.'</div>');
        case 'sucesso':
            $CI->session->set_flashdata($id, '<div class="alert-box sucess radius">'.$msg.'</div>');
            $CI->session->set_flashdata($id, '<div class="alert-box radius">'.$msg.'</div>');

//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.
            echo $flash;
            return TRUE;
            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!


For this case I would replace it with:

$this->session->sess_regenerate(TRUE); // TRUE here destroys the session data.


If all you are doing is showing a message that the user successfully logged out, then why not just redirect to a place where the message is displayed. For instance /login?logout=1. By doing that, the user can choose to log back in again, and you can use the logout query parameter to show the logout confirmation.

(This post was last modified: 11-12-2015, 05:21 PM by CroNiX.)


Theme © iAndrew 2016 - Forum software by © MyBB