title: Session cookies not working in Electron
body: <p>I'm looking at implementing a login system in an Electron[0] application which I'm building but getting stuck on the part of handling the session. Basically I want to store the users session so it is persisted between application restarts (if "Remember me" is enabled).</p>
  
  <p>I have to make use of an existing back-end which works with cookie authentication and I'm not able to change anything there.</p>
  
  <p>From the Electron documentation on the Session object[1] I gathered that I should be using a partition like f.e. <code>persist:someName</code> in order to have a persistent storage, but this is not persisted between application restarts as it seems.</p>
  
  <p>The way I currently set the cookie is as follows:  </p>
  
  <pre><code>// main-process/login.js
  
  const session = require('electron').session;
  
  const currentSession = session.fromPartition('persist:someName').cookies;
  
  currentSession.set({
      name: 'myCookie',
      url: 'https://www.example.com',
      value: 'loggedin=1',
      expirationDate: 1531036000
  }, function(error) {
      console.log('Cookie set');
      if (error) {
          console.dir(error);
      }
  });
  </code></pre>
  
  <p>After running this, I see the <code>Cookie set</code> output, but when restarting the app and running the following code:</p>
  
  <pre><code>// main.js
  
  const session = require('electron').session;
  
  const currentSession = session.fromPartition('persist:someName').cookies;
  
  currentSession.get({}, function(error, cookies) {
      console.dir(cookies);
      if (error) {
          console.dir(error);
      }
  });
  </code></pre>
  
  <p>The output returned is <code>[]</code>.</p>
  
  <p>Any pointers as to what I'm doing wrong or need to do differently would be highly appreciated!</p>
  
  <p>[0] <a href="http://electron.atom.io" rel="noreferrer">http://electron.atom.io</a><br>
  [1] <a href="http://electron.atom.io/docs/api/session/" rel="noreferrer">http://electron.atom.io/docs/api/session/</a></p>