A customer logs out of a web application on a shared computer. The authentication session ends, but previously downloaded documents, locally stored preferences and application data may still exist in the browser.
Modern web applications store information in more places than traditional session cookies. IndexedDB databases, service workers and browser caches can all contribute to an experience that persists beyond the authenticated session.
The Clear-Site-Data HTTP response header gives developers another tool for managing this persistence. Its real value depends on understanding both what it removes and the consequences of removing it.
Logout has two independent responsibilities
The server must invalidate the authentication state, preventing a previously issued session identifier or revoked token from authorizing further requests. The browser must also stop exposing application information that should no longer be available to the signed-out user.
These responsibilities are complementary. Deleting browser data cannot invalidate credentials copied elsewhere, while invalidating a server session does not necessarily remove information already stored locally.
User requests logout
|
v
Server invalidates session
|
v
HTTPS logout response
|
+-- Authentication cookie expires
|
+-- Clear-Site-Data instructs browser
|
v
Unauthenticated application stateChoose what should disappear
Clear-Site-Data accepts quoted directives describing categories of information that a supporting browser should remove. An application can select specific categories instead of requesting a complete reset.
| Directive | Application concern |
|---|---|
| “cache” | Previously cached resources |
| “cookies” | Authentication and other cookies within the applicable domain scope |
| “storage” | Persistent application databases and browser-managed storage |
| “*” | All supported categories, including future additions |
The header requires a secure context. Developers should verify directive-specific compatibility before making browser-side deletion an essential part of a privacy workflow.
Integrating the header into a PHP application
A framework-independent logout response might include the following header configuration. The example assumes authentication has already been invalidated by the application’s existing logout handler.
<?php
// After authorized logout processing
// and successful session invalidation:
header('Cache-Control: no-store');
header('Clear-Site-Data: "cache", "storage"');
header('Content-Type: text/plain; charset=UTF-8');
echo 'You have been signed out.';The actual authentication cookie should also be expired using matching cookie attributes. This example intentionally avoids the cookies directive because domain-wide cookie deletion may affect neighboring applications.
Logout endpoints should use the application’s established authorization and cross-site request forgery protections. Otherwise, an unrelated website might cause unwanted logout requests or destructive client-side resets.
A surprising risk: neighboring applications
Imagine a company operates a customer portal, an internal dashboard and a documentation website under related subdomains. Clearing cookies from one application can affect more than that application’s own session.
Before deploying broad deletion directives, document which browser resources are shared across products. A company may intentionally synchronize authentication between services, but it may also expect independent sessions to remain active. Those two architectural choices imply different logout behavior.
Offline applications require special attention
An offline-first application may contain locally stored drafts, pending transactions or cached documents. Removing storage indiscriminately could discard unsynchronized work or unregister the service worker responsible for offline functionality.
The logout experience must distinguish confidential data from durable user work. Depending on the product, users may need an opportunity to synchronize drafts before signing out, or the application may need an account-specific storage model that supports selective removal.
Clear-Site-Data is better suited to broad category-level cleanup than to carefully preserving selected records inside a local database. Selective deletion requires a more targeted application design.
Build a logout verification matrix
| Test | Expected behavior |
|---|---|
| Replay the previous session credential | Protected requests are rejected |
| Use browser Back navigation | Confidential screens are not exposed |
| Inspect local storage | Targeted application data is removed |
| Open another authenticated tab | The interface transitions safely to signed-out state |
| Visit a related subdomain | Session behavior matches the documented policy |
Run these tests in supported browsers using realistic application data. Pay particular attention to service workers, open tabs and offline behavior. An apparent success in one browser’s storage inspector is not sufficient evidence that the complete logout experience is safe.
Browser cleanup is not universal erasure
The header cannot retract information a user has already downloaded, copied, photographed or transmitted elsewhere. Nor does it delete server-side records or guarantee that a separate browser profile contains no copies of the information.
Applications handling confidential content should minimize unnecessary persistence from the beginning and apply appropriate caching policies when delivering sensitive responses. Cleanup after logout is an additional protective measure rather than a replacement for secure data handling throughout the session.
A well-designed logout operation is therefore more than a redirect to a login page. It is a deliberate transition between authenticated and unauthenticated states, supported by server-side revocation, appropriate client-side cleanup and tested behavior across the application’s real deployment environment.























