For setting a cookie in the client side we usually go for normal javascript. Here i found one article where we can use jquery plugin to do the cookie manipulation. The code is very use and easy to manipulate. For more details check it here
There are different ways we can build an HTML string . I was going through one article which clearly gives the different ways including benchmark results. For more information head over at this link