How to retrieve load page cookies?
Closed this issue · 4 comments
cxfksword commented
I create a new window with web page url. ex:
var w, _ = a.NewWindow("https://test.com/login", &astilectron.WindowOptions{
Center: astikit.BoolPtr(true),
Height: astikit.IntPtr(360),
Width: astikit.IntPtr(420),
})
When page loaded, how to retrieve all page cookies (include HttpOnly cookie)?
asticode commented
You will be able to retrieve page cookies only in your JS using these APIs.
Use something like this to retrieve the session
object :
const session = require('electron').remote.session
cxfksword commented
Thanks your reply.
I have retrieved cookies in preload using JS, when i want to send cookies to go by astilectron.sendMessage
, astilectron
is undefined, why?
asticode commented
Make sure you're executing astilectron.sendMessage
once you've received astilectron-ready
event:
// This will wait for the astilectron namespace to be ready
document.addEventListener('astilectron-ready', function() {
// This will send a message to GO
astilectron.sendMessage("hello", function(message) {
console.log("received " + message)
});
})
cxfksword commented
Thanks, I has succeeded. But this way can't retrieve HttpOnly
cookie. 😂