# View layer state and session variables - ajax necessary?

**URL:** <https://www.ruby-forum.com/t/view-layer-state-and-session-variables-ajax-necessary/174778>\
**Category:** Rails\
**Created:** [September 2, 2009, 2:52am UTC](https://www.ruby-forum.com/t/view-layer-state-and-session-variables-ajax-necessary/174778 "2009-09-02T02:52:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunaclaire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@lunaclaire](https://www.ruby-forum.com/u/lunaclaire)\
**Post date:** [September 2, 2009, 2:52am UTC](https://www.ruby-forum.com/t/view-layer-state-and-session-variables-ajax-necessary/174778/1 "2009-09-02T02:52:01Z")

</div>

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?
