How to use the cookies.setResponseCookie function in cookies

To help you get started, we’ve selected a few cookies examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github caolan / blog / packages / duality / duality / core.js View on Github external
if (!(res instanceof Object)) {
        res = {code: 200, body: res};
    }
    else {
        res = exports.parseResponse(req, res);
    }
    events.emit('beforeResponseStart', info, req, res);
    events.emit('beforeResponseData', info, req, res, res.body || '');

    if (flashmessages) {
        res = flashmessages.updateResponse(req, res);
    } else {
        // set the baseURL cookie for the browser
        var baseURL = utils.getBaseURL(req);
        cookies.setResponseCookie(req, res, {
            name: 'baseURL',
            value : baseURL,
            path : baseURL
        });
    }
    req.response_received = true;
    return res;
};
github caolan / blog / packages / duality / duality / core.js View on Github external
start = function (res) {
        start_res = res;
        events.emit('beforeResponseStart', info, req, res);
        if (res.body) {
            events.emit('beforeResponseData', info, req, res, res.body);
        }
        if (flashmessages) {
            res = flashmessages.updateResponse(req, res);
        } else {
                // set the baseURL cookie for the browser
                var baseURL = utils.getBaseURL(req);
                cookies.setResponseCookie(req, res, {
                    name: 'baseURL',
                    value : baseURL,
                    path : baseURL
                });
        }
        _start(res);
    };
    var _send = send;
github kanso / kanso / packages / duality-flashmessages / duality / flashmessages.js View on Github external
exports.updateResponse = function (req, res) {
    var messages = _.map(exports.getOutgoingMessages(req), function (val) {
        delete val.outgoing;
        delete val.incoming;
        return val;
    });
    if (req.response_received) {
        exports.setBrowserCookie(req, messages);
    }
    else {
        cookies.setResponseCookie(req, res, {
            name: '_duality_flash',
            value: JSON.stringify(messages),
            path: require('duality/core').getBaseURL(req) + '/'
        });
    }
    return res;
};