Use the jquery_cookie() plugin for this.
$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
Where the_cookie
is the name of your cookie. and where the_value
of your cookie is the value/function it has to do.
expires 7
means that the cookie wil expire in 7 days (one week)
Path
isn't nessesary,
Define the path where the cookie is valid. By default the path of the
cookie is the path of the page where the cookie was created (standard
browser behavior). If you want to make it available for instance
across the entire domain use path: '/'. Default: path of page where
the cookie was created.
You can remove the cookie using:
$.removeCookie('the_cookie');
you can read the cookie using:
$.cookie('the_cookie');
Hope it helps.