Electron Cookie API


#1

Hey Everyone,

Looking for some advice on setting a cookie. I am saving a value of a specific cookie to some local storage in my app. Then I am setting the data from that local storage to a variable to use as the value detail when using the session.cookies API in electron. I can log the value in the console and its the one Im looking for but the value isn’t being set in the cookie. Here is what I have written:

fs.readFile('path/to/file', 'utf8', function(err,data){
    if (err) {
      return console.log(err);
    }
      console.log(data);
    spWindow.webContents.session.cookies.set(
      { url : "http://www.google.com",
        name : "_spapp_session",
        value : data },
      function (error){
        if (error) throw error;
      });
   });

I data has my cookie value. I know value takes a string type but Im just not sure what to do from here. Any advice would be greatly appreciated! Thanks for all your time!

-Alec


#2

Issue has been solved! Had to do with how I was writing the file!