Setting session or partition in BrowserWindow / Webpreferences not working

Viewed 1046

I am trying to save cookies to a named session. The cookies are saved in session.defaultSession and get() does return them.

Here I'm attempting to set the partition

mainSession = session.fromPartition("persist:myapi");

Then this function when app.on('ready') is event.

const createMainWindow = () => {
  mainWindow = new BrowserWindow({
    webPreferences: {
      nodeIntegration: true,
      webviewTag: true,
      //session: mainSession,
      partition: mainSession
    },
    .....
  });

Later after response received I check mainSession and it is empty {}.

Using v 7.1.11

Perhaps the problem is related to my cookie. My electron browserWindow.loadUrl is a local html file. It presents a log in screen to an API. The cookie is returned from the API and while it shows up in session.defaultSession it does not show in devtools (like a typical cookie would in a browser).

0 Answers
Related