Session.cookies are empty while JavaScript document.cookie are not


#1

Hey all

I want to get all the cookies from a BrowserWindow object, including HTTPonly cookies.
I’ve read through the documentation that the following code will output all the cookies being used in the BrowserWindow:
windowObject.webContents.session.cookies.
This returns an empty cookies object: Cookies: {}.

If I use the following code, I do get all the cookies except for the much needed HTTPonly (which are not returned due to security purposes):
return windowObject.webContents.executeJavaScript(`document.cookie;`, true).then(function(result){ console.log(result); });

Why is it that the session returns no cookies? How can this be fixed?

I’m using Electron: 1.7.5

Thanks for your help in advance!