The client's webapp appearance is modelled on directory tree displays. Clicking on icons expands the branch and clicking on icons in the branch expands the subbranch and so on. Likewise clicking on the icon at the top of an expanded branch closes/collapses the branch. Each icon is a button and places a call to the webserver. I initially thought I would replace the icons/buttons with Javascript because the response would be much faster and (I thought) there was no need to bother the webserver. So I looked at half a dozen examples available on the Net. Some people even want you to pay for their scripts. The neatest one I found sets up a tree in the browser's DOM and then changes an attribute so the browser can see or not see the branch as it repaints the page. This is (largely) browser independent.
But this turned out to be all irrelevant. I didn't realise at first but have now discovered that the client's app refreshes its data via a web service call every time an icon is clicked. So I might as well process the expand/collapse calls on the webserver.
This is where the session handling becomes critical and why I'm glad I chose CGI::Application. I created a four-level array of hashes (Days/Branches/Jobs/Items) to hold the state of the display then having use'd CGI::Application::Plugin::Session earlier on I simply added two lines of code:
$self->session->param('DAYS', $self->{Days});to save the array between calls and
$self->{Days} = $self->session->param('DAYS');to retrieve it next time the page is called. Cookies and data serialisation and storage are all handled by the module. Ah laziness! Let me count thy ways!