title: Separate cookies of multiple windows
body: <p>I'd like to write an <a href="https://www.electronjs.org/" rel="nofollow noreferrer">electron</a> app, which is based on a number of windows.</p>
  <p>Using this app, I'd like to be able to log in into a web-app using different roles in different windows.</p>
  <p>Therefore, I need a feature to store cookies in different windows of the app at different locations. <strong>HTML, JS code and cookies</strong> data of window A should <strong>not see</strong> that of windows B.</p>
  <p>Alternatively, I could image to somehow <strong>trap set-cookie requests</strong> and keep them in memory, thus <strong>not using app global cookie storage on HD</strong>.</p>
  <blockquote>
  <p>Could someone provide code for this feature?</p>
  </blockquote>
  <p>I'm aware of <a href="https://stackoverflow.com/questions/48587035/electron-how-to-set-a-custom-directory-for-user-data-user-data-dir">this post</a>, which explains how to <a href="https://www.electronjs.org/docs/api/app#appsetpathname-path" rel="nofollow noreferrer">app.setPath()</a> of <code>userData</code>. Unfortunately <code>userData</code> is app-global, not e.g. window local.</p>
  <p>If I would be now able to trap each <code>cookie-set</code> operation of each <a href="https://www.electronjs.org/docs/api/browser-window" rel="nofollow noreferrer">BrowserWindow</a>, I would be able to use <code>app.setPath()</code> and switch the cookie storage based on the window, the trap was fired.</p>