Here’s the basic idea of one way to manage cookies with JavaScript. As always, there are more robust libraries available, but here’s the upshot:

var CookieManager = function(){};
CookieManager.instance = null;
CookieManager.getInstance = function(){
    if(CookieManager.instance == null){
        CookieManager.instance = new CookieManager();
    }
    return CookieManager.instance;
};
CookieManager.prototype.get = function(key){
    key = key + "=";
    var parts = document.cookie.split(';');
    for (var i = 0; i < parts.length; i++) {
        var segment = parts[i];
        segment = segment.trim();
        if (segment.indexOf(key) === 0) {
            var value = segment.substring(key.length);
            return decodeURIComponent(value);
        }
    }
};
CookieManager.prototype.set = function(key, value, expires){
    var output = key + '=' + encodeURIComponent(value);
    if (expires) {
        output += "; expires=" + expires;
    }
    document.cookie = output;
};
CookieManager.prototype.getDateFromDuration = function(days){
    var date = new Date();
    var milliseconds = days * 24 * 60 * 60 * 1000;
    var now = date.getTime();
    var then = now + milliseconds;
    date.setTime( then );
    return date.toUTCString();
};

POC: http://jsfiddle.net/moagrius/kwctsnyq/