CodeIgniter Forums
logout sometimes not working and need to logout again - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: logout sometimes not working and need to logout again (/showthread.php?tid=65677)



logout sometimes not working and need to logout again - rchiu5hk - 07-11-2016

Dear all,

I have below to handle logout and display information in the header to show after logout. But sometimes, it is unsuccessful. I suspect whether it is good to write this code to handle. Do you have any ideas? Please help


Code:
public function logout(){
        $this->nativesession->delete('user');
        redirect(base_url()); }

In header section of the php page:

Code:
<?php $usr = $this->nativesession->get('user');
     if(!isset($usr) || empty($usr) || $usr["username"]==null) {
               // show login button
          }