Search code examples
phpcodeignitersessionlogoutbrowser-history

how to remove browser history in codeigniter?


Hi I am working on a project (PHP-CodeIgniter, MySQL). In my application I am creating session for users data(userid, username) after successful login by the user and unset the session after signout.

"Here the main problem if i click on back button of browser I can able to see the previously visited pages in my application after signout also".

How can prevent this with codeigniter?

Thanks in advance


Solution

  • Just add these lines in .htaccess after RewriteEngine on

    <Files *>
        Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0"
        Header set Expires: 0
        Header set Pragma: no-cache
    </Files>
    

    I prefer this because we need to add this at only one place(.htaccess) and it affect the entire application.