view layer state and session variables - ajax necessary?

I have a new interaction on a couple pages where I let the user
collapse/expand a side panel. I'd like to save state, so that when
the page is loaded subsequently, I can show each panel in its previous
state.\

After reading around, it seems that since javascript cant set server-
side session variables, the 2 approaches mentioned are to set a cookie
or to go with ajax.

Not sure how I feel yet about the cookie approach, but a round trip
back to the server for a client-side interaction doesnt seem like the
best approach.

Do others feel the same way or am I missing something here?

Are there other approaches suggested?