Set a cookie in jQuery

Set a cookie in jQuery

How can I set a cookie when a background color is changed? I created a basic switcher which changes the body color, but I want to save the changed color in a cookie.

jQuery code:

    

        $('.first li ').click(function (e) {

            e.preventDefault(); $(this).parent().parent().find('img').removeClass('active');

            $(this).addClass('active');

        });

        $('.first li').click(function (e) {

            e.preventDefault(); $(this).parent().parent().find('img').removeClass('active');

            $(this).addClass('active');

             var src = $(this).find('img').attr('src');

            $('body').css('backgroundImage', 'url(' + src + ')');

           $.cookie('backgroundImage', bg, { expires: 365, path: '/' });

           if ($.cookie("backgroundImage")) { $('body').css('backgroundImage', $.cookie("backgroundImage")); } 


     });


http://jsfiddle.net/5HV28/