ElectronJs:如何在主流程中获取BrowserWindow中的cookie数据

时间:2016-05-26 09:17:05

标签: node.js cookies chromium electron

我正在app.js

中创建一个cookie
/// cookies test
const session = require('electron').session;
const ses = session.fromPartition('persist:name');

debugger;
// Query all cookies associated with a specific url.
ses.cookies.get({}, (error, cookies) => {
    debugger;

    console.log(cookies); /// cookies values should be printed next time the applciation is launched.
});

// Set a cookie with the given cookie data;
// may overwrite equivalent cookies if they exist.
const cookie = {
    url: 'http://www.github.com',
    name: 'dummy_name',
    value: 'dummy',
    expirationDate: 2093792393999
};
ses.cookies.set(cookie, (error) => {
    debugger;

    if (error)
        console.error(error);

    ses.cookies.get({}, (error, cookies) => {
        console.log(cookies); /// cookies values should be printed next time the applciation is launched.
    });
});

我需要将cookie的数据访问到渲染过程中。怎么做?

0 个答案:

没有答案