-
Notifications
You must be signed in to change notification settings - Fork 270
Description
Article URL
On what page did you find the problem?

- Setting cookie in OfficeJS Dialog API window is not reflected in Taskpane window in Desktop Excel office-js#3519
- https://stackoverflow.com/a/64053067/24558122
Describe the problem
A clear and concise description of what is incorrect, unclear, or missing in the document.
I want to understand more on the following. I could not find the details in the official documentation. Would appreciate any help.
I'm developing an Office Add-in where the main page (task pane) redirects to a login page under the same domain if no session cookie is present. As per recommended practice, I plan to open the login page in an Office dialog. The user will complete SSO within the dialog, and the server will set a session cookie. Upon successful login, the dialog will close and return a success message to the task pane.
The task pane should then have access to the session cookie set during the dialog-based login.
According to GitHub Issue #3519, cookies should be shared between the dialog and the task pane, but there is no clear official documentation confirming this. The only related reference appears to be in this Microsoft Learn article, which states:
"Store shared data in a cookie for the add-in's domain to share it between browser runtimes. JavaScript-only runtimes don't support cookies."
Could the Office team please clarify whether session cookies set in the dialog are accessible in the task pane, especially for WebView2-based add-ins?
Some WebView2 documentation and posts like this one on Stack Overflow mention that each WebView2 session is tied to a single user data folder (UDF). A UDF can only be associated with one WebView2 session at a time. Any WebView2 control that uses the same UDF shares that session, regardless of whether the controls are in the same host application or spread across different ones.
When Office applications use WebView2, they should typically configure both the taskpane and dialog instances to use the same User Data Folder. This shared UDF means that:
- Cookies set in one WebView2 instance are stored in the shared UDF
- Other WebView2 instances using the same UDF can access these cookies
- WebView2 stores all state including cookies, localStorage, indexeddb and so on, in the user data folder
Screenshots
If applicable, add screenshots to help explain your problem.