Load Cookies - Node.js Environment

Node.js examples for Environment:Cookie

Description

Load Cookies

Demo Code

function loadCookies() {
    var cookies;/*ww  w .  j av a  2  s .  c o  m*/
    try {
        if (fs.exists(fs.absolute('./cookies.js'))) {
            cookies = require(fs.absolute('./cookies.js'))();
        } else {
            return;
        }

        cookies.forEach(function eachCookie(cookie) {
            phantom.addCookie(cookie);
        });
    } catch(e) {
        console.trace(e);
        phantom.exit(1);
    }
}

Related Tutorials