Prevent Back Login After Logout by hitting the Back button on your Browser

Submitted by cyberid41 - 9 years ago

Hello what if your application when it is logout then you intentionally hit the back button on your web browser, what happened? your application will be returned to the original page, which should be redirected to the login page. Here I share a simple trick, put on a filters.php

// filters.php
App::after(function ($request, $response) {
    // Mencegah Kembali Login Setelah Logout dengan Menekan Tombol Back pada Browser
    $response->headers->set("Cache-Control","no-cache,no-store, must-revalidate");
    $response->headers->set("Pragma", "no-cache"); //HTTP 1.0
    $response->headers->set("Expires"," Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past