2
votes

My problem is I want to do when I already logout, If I click back button on browser it never back admin home page.

Now when I click back button It show admin secret pages, But when I refresh the page then It back to login page.

I solved it write the code in filter.php on Laravel 4.2

App::after(function($request, $response)
{
 $response->headers->set('Cache-Control','nocache, no-store, max-age=0, must-revalidate');
$response->headers->set('Pragma','no-cache');
$response->headers->set('Expires','Fri, 01 Jan 1990 00:00:00 GMT');
});

But Now how can I do Prevent Back Login After Logout by hitting the Back button on Browser in L5?

2

2 Answers

10
votes

Keep this line in top of the login page.That will clear cache and prevent back page(pabel)

<?php echo
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-Type: text/html');?>
4
votes

that work for me:

Put this javascript code at the end of your login page, with this you can not go back and then once outside the system can not reach the previous pages

 <script>
    window.onload = function () {
        if (typeof history.pushState === "function") {
            history.pushState("jibberish", null, null);
            window.onpopstate = function () {
                history.pushState('newjibberish', null, null);
            };
        } else {
            var ignoreHashChange = true;
            window.onhashchange = function () {
                if (!ignoreHashChange) {
                    ignoreHashChange = true;
                    window.location.hash = Math.random();
                } else {
                    ignoreHashChange = false;   
                }
            };
        }
    }
 </script>