logo
search
Office Compatibility Issues

Fix Excel Add-ins Cannot Read Cookies with JavaScript API

Elise WilliamsElise Williams Oct 10, 2026 868 views

Question details

The user needs to understand why document.cookie returns an empty value in an Excel Office Add-in and is looking for safer alternative ways to store authentication tokens.

Why Excel Add-ins Cannot Read Cookies with the JavaScript API
Product
Excel
Device & OS
not provided
Scenario
Developing or troubleshooting an Excel Office Add-in that relies on client-side JavaScript to read authentication cookies.
Observed behavior
The document.cookie property returns an empty value because the Office Add-in environment restricts cookie access.
Before you start

Before modifying your add-in's authentication flow, check your browser's privacy and third-party cookie settings, as strict tracking prevention can further impact iframe storage behavior.

Solution 1Recommended

Configure the Shared Runtime in Your Add-in Manifest

Using a shared runtime allows the task pane, custom functions, and dialogs to run in the same browser runtime, potentially bypassing some cookie and storage isolation issues.

By default, Excel custom functions run in a separate JavaScript runtime from the task pane. This separation means they do not share global variables or the same cookie context.

Configuring your add-in to use a shared runtime ensures all components execute in the same hidden browser process, unifying access to local storage and applicable cookies.

1
Open your manifest.xml file

Locate the manifest.xml file in the root directory of your Excel Add-in project.

2
Add the shared runtime requirement

Insert the <Requirements> tag and specify <Set Name="SharedRuntime" MinVersion="1.1"/> to ensure the host supports it.

3
Update the Runtimes section

Add a <Host Name="Workbook"> section and define your <Runtime resid="Taskpane.Url" lifetime="long" /> to connect the UI and custom functions.

Configure the Shared Runtime in Your Add-in Manifest
Compatibility Check: Shared runtime is supported on Windows (Edge WebView2), Mac, and Web, but always verify your specific minimum Excel version requirements.
Free Microsoft Office alternative

Try WPS Office for Your Spreadsheet Needs

While developing and troubleshooting custom JavaScript add-ins for Excel can lead to complex iframe sandboxing and authentication hurdles, managing your daily spreadsheet tasks shouldn't be difficult. WPS Office offers a free, lightweight, and highly compatible alternative to Microsoft Office, providing powerful built-in tools without the need to rely on complex third-party extensions.

  1. 1. Download the installer: Visit the official WPS Office website and download the free installation package for your operating system.
  2. 2. Install WPS Office: Run the setup file and follow the on-screen instructions for a quick, lightweight installation.
  3. 3. Open your spreadsheets seamlessly: Launch WPS Spreadsheets and open your existing .xlsx files directly. The format and layouts will be perfectly preserved.
Completely free and lightweight Office suiteHigh compatibility with Microsoft Excel (.xlsx, .xls) formatsFamiliar user interface ensuring seamless migration with zero learning curveRobust built-in data analysis tools preventing the need for buggy add-ins
microsoft office alternative - wps office

Frequently Asked Questions

Why do custom functions in Excel act differently with cookies?

By default, Excel custom functions execute in a separate JavaScript runtime independent of the main task pane. Because they run in an isolated environment, they do not share the same cookie, localStorage, or sessionStorage context as the task pane unless a Shared Runtime is explicitly configured in the manifest.

Can I use localStorage instead of cookies in an Office Add-in?

Yes. While cookies are often blocked due to strict third-party iframe restrictions, localStorage and sessionStorage are generally supported within the task pane's browser control context and serve as the recommended alternatives for storing authentication tokens.

Does the user's browser choice impact cookie access in Excel Add-ins?

Yes. Excel Add-ins use built-in browser controls (like Edge WebView2 on Windows or WebKit on Mac). If the underlying browser's privacy settings are configured to block third-party cookies or enforce strict tracking prevention, the add-in will be unable to read or write standard cookies.