Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logout issue in code igniter (PHP)

I am storing loginuserid in session and destroy session on logout . login and logout work fine but my problem is when user logout and we press back button it still able to open visited page and even when he is actualy loged out .

User go to login page when we refresh the page . I want user not go to visited page even he press back button . Please help me out . Thanks in Advance .

like image 828
user1777954 Avatar asked Dec 28 '25 16:12

user1777954


1 Answers

This is actually because of the browser caching - you should disable this and use CodeIgniters Cache Library if any caching is needed.

Add the following to the pages where users are required to be logged in:

//Prevent browsers from using history to browse in the user system.
$this->CI->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->CI->output->set_header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
$this->CI->output->set_header("Pragma: no-cache"); 

When pressing back in the browser the page will be refreshed,

like image 88
Repox Avatar answered Dec 31 '25 17:12

Repox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!