Welcome Guest, Not a member yet? Register   Sign In
fail to set flashdata after destroy session on logout
#1

(This post was last modified: 05-26-2020, 07:33 AM by nmaa3003.)

hi, 

this is my code:
PHP Code:
    public function logout()
    {
        $adminModel = new AdminModel();
        $category 'last_logout';
        $merchant $this->session->get('merchant');
        $action $merchant->email ' has logged out!';
        $adminModel->set_merchant_logs($merchant->id$category$action);

        $this->session->destroy();
        $this->session->setFlashdata('success''You have successfully logged out!');
        return redirect()->to('/merchant/login');
    

so, notice that i setFlashdata after session destroy.
it's not triggering the flashdata when redirected to login page.

was that intentional or was that a bug?
Thanks.

just found solution, just use $this->session->remove('merchant');
Reply
#2

I have the same problem Sad
Reply
#3

I think you could also do:
return redirect()->to('/merchant/login')->withCookies();
Reply
#4

(11-09-2021, 10:05 AM)Halim Wrote: I have the same problem Sad

The session is destroyed. There is no place to put the flash data. The session is not created again until the controller class that creates the next page is executed which is after the set flash data statement.
Simpler is always better
Reply




Theme © iAndrew 2016 - Forum software by © MyBB