Pablo Fernandez
Pablo Fernandez

Reputation: 287410

How to set cookies in an electron webview?

When retrieving cookies from an Electron WebView using cookies.get, I get an array of cookie objects. So far so good. But when I try to set them back with cookie.set, it is expecting an URL:

url String - The url to associate the cookie with.

which is not exported by get. This is on top of domain and path. How am I supposed to set the cookies again? Why is it even asking for a URL, aren't cookies associated by domain and path instead of a URL?

When I try to set them I get the very useful error of "Error: Setting cookie failed" and I'm just guessing it's the missing non-optional URL attribute.

Upvotes: 4

Views: 3533

Answers (1)

Robin
Robin

Reputation: 129

Add a url variable to your cookie with the domain of the site whose belong the cookie:

cookie.url = "http://example.com/";

Upvotes: 1

Related Questions