Welcome Guest, Not a member yet? Register   Sign In
set_flashdata stays open
#1

I am developing a web project which I am about to finish, using CodeIgniter 3. In this web application I am developing I am using flash messages to indicate to the user that certain operations have been performed successfully, for example, when logging in, logging out, editing an entry, etc...
The problem is that, even though I do redirect after creating the messages, they stay on screen all the time, even when I switch from one link to another.

I have searched for information and I have seen that it is necessary to make redirect after the creation of each one of the alerts, but I do that correctly and still they remain on screen all the time. Sometimes I even, I don't know why but, I shut down the server, restart the computer and when I log in these messages are still on screen, when they should be removed the next time I click on a link or reload the page.

This is the code for the logout method, wich displays a message that says that the operation was performed successfully. (Sorry is in spanish but the code is very legible).


Code:
public function logout(){
            //Unset data
            $this->session->unset_userdata('logged_id');
            $this->session->unset_userdata('user_id');
            $this->session->unset_userdata('username');

            //mensaje
            $this->session->set_flashdata('usuario_logout','Has cerrado sesión. ¡Hasta pronto!');

            redirect('usuarios/login');

        }

And here is the part of the header that displays the messages (in header.php):


Code:
<div class="container">
    <?php if($this->session->flashdata('usuario_logout')): ?>
      <?php echo '<p class="alert alert-info">'.$this->session->flashdata('usuario_logout').'</p>'; ?>
    <?php endif; ?>
</div>

Do any of you know what is going on here and why the messages are not disappearing?

Thank you in advance!
Reply


Messages In This Thread
set_flashdata stays open - by pedreitor - 03-16-2021, 04:16 AM
RE: set_flashdata stays open - by php_rocs - 03-16-2021, 06:55 AM
RE: set_flashdata stays open - by pedreitor - 03-17-2021, 09:05 AM
RE: set_flashdata stays open - by php_rocs - 03-18-2021, 08:04 AM
RE: set_flashdata stays open - by pedreitor - 03-18-2021, 12:03 PM
RE: set_flashdata stays open - by php_rocs - 03-18-2021, 02:27 PM
RE: set_flashdata stays open - by pedreitor - 03-22-2021, 12:12 PM
RE: set_flashdata stays open - by pedreitor - 03-22-2021, 02:20 PM
RE: set_flashdata stays open - by InsiteFX - 03-22-2021, 08:45 PM
RE: set_flashdata stays open - by pedreitor - 03-23-2021, 03:24 AM
RE: set_flashdata stays open - by php_rocs - 03-23-2021, 06:29 AM
RE: set_flashdata stays open - by demyr - 03-23-2021, 02:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB