You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I agree to follow the Code of Conduct that this project adheres to.
I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
Electron Version:5.0.1
Operating System:mac OSX 10.14.4
Last Known Working Electron version:: 4.x
Expected Behavior
I should be able to set/remove a cookie.
Actual Behavior
I cannot set or remove a cookie
To Reproduce
import{session}from'electron'asyncfunctiontestCookies(){if(!session||!session.defaultSession)thrownewError('Could not get default user session')constcookies=session.defaultSession.cookiesconstname='foo'consturl='/'awaitcookies.set({
url,
name,value: 'Hello World!',expirationDate: 99999999.0,})console.log('COOKIES BEFORE:',awaitcookies.get({}))awaitcookies.remove(url,name)console.log('COOKIES AFTER:',awaitcookies.get({}))}//....app.on('ready',()=>{testCookies()})
Additional Information
Running this on a Mac and have tried many permutations of the above but can't get anything to work. Things seemed to work in 4.x
The text was updated successfully, but these errors were encountered:
I seem to be having similar problems with localStorage. It's now cleared between sessions -- but only in a packaged app. Works fine in dev.
My problem with LocalStorage is being caused by a stale LOCK file that is left behind when an application is quit (using app.quit()). Apparently, internal state data is transferred to a LevelDB database on quit, but the lock file on the database isn't properly cleaned up.
@deermichel and I investigated further into this issue, but couldn't find anything wrong with cookie support in v5.0.3
Here's a link to a gist you can paste into Electron Fiddle. This contains a minimum working example for the Cookies API (also available under Show Me -> Electron APIs -> Cookies in the Fiddle menu bar).
Please let us know if the below comments don't solve your issue.
After some investigation, there seems to be a problem in the parameters from your posted example: the expirationDate option uses Unix epoch time, so expirationDate: 99999999.0 would tell your cookie to expire on Saturday, March 3, 1973. This would instantly delete it.
Also, setting url: '/' as an option leads to silent failure in Electron < 6. It should be rejecting the promise instead of resolving it, as the cookie domain associated to the URL is invalid. In this case, the invalid cookie will be unable to be filtered using the cookie.get({ url }) nor removed using cookie.remove({ url }).
This is a bug on Electron's end, and a fix was proposed in #18756 to prevent invalid cookies from being generated for Electron <=5. This problem has been fixed already as of the Electron 6 beta, as the cookie error handling logic was improved.
Putting it all together, here is a working gist for Electron Fiddle with some modifications to your original code.
Preflight Checklist
Issue Details
5.0.1
mac OSX 10.14.4
4.x
Expected Behavior
I should be able to set/remove a cookie.
Actual Behavior
I cannot set or remove a cookie
To Reproduce
Additional Information
Running this on a Mac and have tried many permutations of the above but can't get anything to work. Things seemed to work in 4.x
The text was updated successfully, but these errors were encountered: