Not hard at all. BUT...
Are you aware that cookies are limited to 4KB in size?
It's quite possible that what you are asking for would exceed that size.
If you are willing to live with only more modern browsers being able to use your site, you could use Local Storage, instead.
p.s.: Saving state is easier than restoring it. But neither is a major task.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.