How to Inspect Cookies and Security Flags in Safari on Mac Using Web Inspector

Modern web security and session management depend heavily on HTTP cookies to authenticate users, maintain shopping cart state, and preserve user preferences. For web developers, security researchers, and systems administrators, auditing cookie parameters is essential to prevent vulnerabilities like Cross-Site Scripting (XSS) session theft and Cross-Site Request Forgery (CSRF). Safari on macOS includes Web Inspector, Apple’s native developer tool suite, which provides detailed inspection of client-side storage, cookie lifetimes, and security protection flags.

Understanding HTTP Cookie Security Flags in WebKit

Apple’s WebKit browser engine enforces strict security constraints around cookies, including Intelligent Tracking Prevention (ITP). When inspecting cookies in Web Inspector, several critical security attributes dictate how Safari handles the data:

  • Secure: Ensures the browser only transmits the cookie over encrypted https:// connections, preventing plaintext transmission across insecure Wi-Fi hotspots.
  • HttpOnly: Blocks client-side JavaScript (e.g., document.cookie) from accessing the cookie value. This is a foundational defence against XSS-based token theft.
  • SameSite: Regulates whether cookies accompany cross-site requests:
    • Strict: The cookie is never sent in third-party contexts, mitigating CSRF attacks.
    • Lax: Cookies are withheld on cross-site subrequests (like images or iframes) but sent when users follow top-level incoming hyperlinks.
    • None: Cookies are transmitted across third-party contexts, strictly requiring the Secure flag.
  • Partitioned (CHIPS): Indicates whether the cookie is stored in partitioned storage per top-level site to protect user privacy across embedded iframes.
  • Expires / Max-Age: Specifies the exact timestamp when the browser discards the cookie from persistent storage. Session cookies omit this field and expire upon browser closure.

Enabling the Develop Menu in Safari on macOS

Before launching Web Inspector, ensure that developer features are unlocked in your Safari preferences:

  1. Launch Safari on your Mac.
  2. In the menu bar, select Safari > Settings (or press Cmd + ,).
  3. Switch to the Advanced tab.
  4. At the bottom of the window, check the box labelled Show features for web developers (in earlier macOS versions, Show Develop menu in menu bar).
  5. Close the Settings window. A new Develop menu now appears in the top macOS menu bar.

Inspecting Cookies via the Web Inspector Storage Tab

To inspect active cookies for any loaded website:

  1. Navigate to the target website in Safari.
  2. Right-click anywhere on the webpage and select Inspect Element, or press Cmd + Option + I.
  3. In the top toolbar of Web Inspector, click the Storage tab.
  4. In the left-hand navigation sidebar, locate and expand the Cookies category.
  5. Click on the domain name of the current origin to view its associated cookie table.
  6. The central pane populates with every active cookie, displaying columns for Name, Value, Domain, Path, Expires, Size, Secure, HttpOnly, and SameSite.

Editing, Adding, and Deleting Cookies for Testing

Web Inspector allows developers to manipulate cookie states in real time to test authentication expiry and session fallbacks:

  • Modifying Values: Double-click any entry in the Value column, type a test string or altered session ID, and press Enter.
  • Deleting a Single Cookie: Select the cookie row and press the Delete key on your keyboard, or right-click the row and choose Delete.
  • Clearing All Origin Cookies: Right-click the domain name in the left sidebar under Cookies and select Clear to purge all session tokens instantly without clearing browser-wide browsing history.
  • Testing Expiry: Modify the date in the Expires column to simulate an expired session, then refresh the page (Cmd + R) to verify whether the web application redirects cleanly to the login screen.

Auditing Third-Party and Partitioned Tracking Cookies

Due to Safari’s Intelligent Tracking Prevention, third-party trackers are systematically restricted. If your web application embeds cross-domain widgets (such as payment gateways or authentication providers), check the Partitioned column in Web Inspector. Cookies lacking proper SameSite=None; Secure; Partitioned attributes will be blocked by WebKit, causing embedded iframes to lose authentication state.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.