<pre id="results"></pre>

<script>
YUI().use('cookie', 'node', function (Y) {

    var results = Y.one('#results'),
        log = function(str) {
            results.append(str + '<br>');
        };

    //set subcookie values
    Y.Cookie.setSub("example", "name", "Yahoo!");
    Y.Cookie.setSub("example", "today", (new Date()).toString());
    Y.Cookie.setSub("example", "count", Math.round(Math.random() * 30));

    //get subcookie values
    var name = Y.Cookie.getSub("example", "name");
    var today = Y.Cookie.getSub("example", "today", function (value) {
        return new Date(value);
    });
    var count = Y.Cookie.getSub("example", "count", Number);
    
    log("The subcookie 'name' is '" + name + "' (" + (typeof name) + ")");
    log("The subcookie 'today' is '" + today + "' (" + (typeof today) + ")");
    log("The subcookie 'count' is '" + count + "' (" + (typeof count) + ")");
       

});
</script>
