/*
    JUST TO WATCH OFFLINE


*/
const fs = require('fs');

var crunch = {};

crunch.session_save = (session)=>{
    var net = `# Netscape HTTP Cookie File\n
    # http://curl.haxx.se/rfc/cookie_spec.html\n
    # This is a generated file!  Do not edit.\n\n`;
    var old_exp = 0;
    for(var i = 0;i<session.length;i++){

        if(typeof session[i].expirationDate == 'undefined'){
            session[i].expirationDate = old_exp;
        }
        if(session[i].expirationDate>old_exp){
            old_exp = session[i].expirationDate;
        }
        net += session[i].domain+'	'+session[i].httpOnly.toString().toUpperCase()+'	'+session[i].path+'	'+session[i].secure.toString().toUpperCase()+'	'+Math.ceil(session[i].expirationDate)+'	'+session[i].name+'	'+session[i].value+'\n';
    }
    //console.log(net);
    /*fs.writeFile(global.dir+"/tmp/c", net, function(err) {
        if(err) {
            return console.log(err);
        }
        //console.log("T!");
    });*/
}

module.exports = crunch;
