The function makeYearExpDate() enables you to set the expiration date for several years in the future. It was designed for really persistent cookies. If you want a shorter time, you can easily modify this routine. Note that this function uses the Date object heavily.
The static method, Date.getTime(), returns a neatly formatted date string, while the method, Date.toGMTime(), returns the date converted to Greenwich Mean Time, which is what the cookie expiration mechanism expects your cookies to contain.