The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →You cannot reliably disable a browser’s Back button with PHP or ordinary page script. Instead, make every protected PHP request verify the user’s current session and permissions, and choose cache headers carefully for sensitive responses. That way, a restored page may briefly appear in browser history, but it cannot be used to fetch protected data or perform protected actions after access has ended.
Why the Back button may still show a page
The browser controls its history. A Back action may restore a page snapshot from the back/forward cache rather than make a fresh request to your PHP application. Even Cache-Control: no-cache does not guarantee revalidation during history navigation; MDN Web Docs explicitly notes that the directive “does not guarantee revalidation for history navigations — such as those made using the Back button.” MDN: Cache-Control
As an Amazon Associate I earn from qualifying purchases.
This creates an important distinction: a user might see previously rendered content, but that does not mean the server should still authorize access. Protect requests and actions on the server rather than treating a particular screen appearing or disappearing as proof of security.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesRequire authentication and authorization on every protected request
Check the session and the user’s permission whenever a protected resource is requested, including after logout, session expiration, or a permissions change. If the check fails, deny the request or redirect to the login page. Apply the same rule to sensitive data endpoints and state-changing actions; hiding a link or redirecting from one page does not protect a separate endpoint.
#1 Best Overall
A minimal plain-PHP gate looks like this:
<?php
session_start();
if (empty($_SESSION['user_id'])) {
header('Location: /login.php', true, 302);
exit;
}
// Also check that this user is authorized for the requested resource.
This illustrates a server-side check, not a complete authentication system or logout routine. Your application must also invalidate the session during logout and apply its own authorization rules to the requested resource.
Choose a cache policy for sensitive responses
Cache headers govern whether responses may be stored and reused; they are not access control. Choose a policy according to the sensitivity of the content and the browser behavior you can accept.
Rank #2
| Directive | Storage and reuse | What it means for browser history |
|---|---|---|
no-cache |
A response may be stored, but ordinary cache reuse requires validation. | It does not guarantee revalidation on Back/Forward navigation; a browser may restore a back/forward-cache snapshot. |
no-store |
Instructs caches not to store the response. | It does not erase a representation already stored at the same URL, and using it broadly can forfeit browser features, including back/forward-cache behavior. |
These semantics and trade-offs are described in MDN’s Cache-Control reference and its HTTP caching guide. For highly sensitive responses, no-store may be appropriate; do not present it as a universal way to disable Back or erase all previously displayed content.
Free tools Windows power users keep installed
One-click scans. No signup required.
Configure PHP session caching without conflicting headers
PHP’s session.cache_limiter controls cache-related headers for session pages. PHP documents nocache, private, private_no_expire, and public; the documented default is nocache. PHP’s session security guidance recommends nocache for authenticated sessions and warns that private caching can expose content on shared clients. See PHP: Securing Session INI Settings and PHP: Session Runtime Configuration.
Set session configuration before starting the session and before sending output. PHP’s session_cache_limiter() controls automatically generated cache headers, while header() can send response headers. Check PHP’s header documentation and avoid having application code, a framework, a reverse proxy, or a CDN silently replace or contradict the intended policy. Do not add another cache policy blindly: first inspect the actual response headers and determine which layer sets them.
Keep session-cookie protections separate from cache policy
Cookie and session settings strengthen session handling; they do not make an already rendered page disappear from browser history. PHP’s session security guidance covers strict mode and cookie protections such as Secure for HTTPS-only sites, HttpOnly, and SameSite. Apply settings appropriate to your deployment, but continue to enforce authorization on each protected request. PHP: Securing Session INI Settings
Rank #4
Test the actual response and logout flow
- Configure the session and cache policy before output, and confirm the framework or server is not overriding it.
- Use browser developer tools or an HTTP client to inspect the headers returned by a protected response.
- Sign in, open a protected page, log out, then try both Back navigation and a fresh request to the protected URL.
- Repeat after session expiration and, where relevant, after a permission change. Confirm that protected requests and actions are denied or redirected when the session or authorization check fails.
Visible results can differ by browser, cache state, framework, proxy or CDN, and response type. A redirect after logout is useful navigation, but it does not remove history entries or replace checks on the destination and other protected endpoints.
Why JavaScript cannot secure this
Calls such as history.back() and history.go(-1) navigate through browser history; they do not secure the resource. location.replace() can replace the current history entry when that behavior suits the application, but it is not an access-control measure. MDN states: “There is no way to clear the session history or to disable the back/forward navigation from unprivileged code.” MDN: Window: history property Avoid redirect loops or scripts that try to rewrite history as a security fix.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




