nw.js: win.cookies.remove() crash on Maverick [$25]

Try to open the nodewebkit app and run the following in the console :

var gui = require('nw.gui');
var win = gui.Window.get();
win.cookies.remove();

the app crash instantanely.

Here’s the log :

http://hastebin.com/teragituqa.avrasm

<bountysource-plugin>

There is a $25 open bounty on this issue. Add to the bounty at Bountysource. </bountysource-plugin>

About this issue

  • Original URL
  • State: closed
  • Created 13 years ago
  • Comments: 25 (4 by maintainers)

Most upvoted comments

Minor modification’s i have done, please let me know if it works for you. It passes my test cases.

function removeCookie(cookie) { var lurl = “http” + (cookie.secure ? “s” : “”) + “😕/” + cookie.domain + cookie.path; nwWin.cookies.remove({ url: lurl, name: cookie.name }, function(result) { if (result) { if (!result.name) { result = result[0]; } // in devTools it looked like the result was an array console.log('cookie remove callback: ’ + result.name + ’ ’ + result.url); } else { console.log(‘cookie removal failed’); } }); }

Thanks

On Fri, Sep 12, 2014 at 4:38 AM, amHammock notifications@github.com wrote:

I’m also trying to delete all cookies after a child window browsing session and cannot get it to work (I need to remove any user sign-in credentials stored in cookies since this app will be running on a public kiosk). I have run this on Mac OSX 10.9.4 and Windows XP

This is my code, constructed as best I can from the Google cookie docs:

gui.App.clearCache(); var nwWin = gui.Window.get(); nwWin.cookies.getAll( {}, function(cookies) { console.log(‘Attempting to remove ‘+cookies.length+’ cookies…’); for (var i=0; i<cookies.length; i++) { removeCookie(cookies[i]); } });

function removeCookie(cookie) { console.log('removing cookie: ’ + cookie.name + ’ : ’ + cookie.domain + cookie.path); nwWin.cookies.remove( { url: cookie.domain, name: cookie.name }, function(result) { if (result) { if (!result.name) { result = result[0]; } // in devTools it looked like the result was an array console.log('cookie remove callback: ‘+result.name+’ '+result.url); } else { console.log(‘cookie removal failed’); } }); }

Lots of promising stuff printed out in the log, no errors reported, I get my callback from removing each cookie, although the result.url field is blank at that point.

But then when I create a new child window and load up some previously used urls, I’m still logged into the various websites so the cookies are still there. Even after restarting the app completely the cookies are still there. I found a “cookies” file in the appData directory; I manually deleted that and restarted the app, finally gave me a clean browsing session. (I actually tried deleting that file in the code but got an ERRBUSY error 😃

I am destroying the child window and doing the clearCache() and the removeCookie code each time the user is done browsing and goes to another part of the app. Then if a new user comes up and opens a browsing session I open a new child window and it should be clean.

Any help? Am I using the API correctly? Is there another way to accomplish this?

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/rogerwang/node-webkit/issues/1678#issuecomment-55341774 .