Keep a Bootstrap collapse menu item open using jquery.cookie.js

Imagine you have a list of collapsible menu items set up using Twitter Bootstrap and all are marked up to default to closed. Clicking each menu heading opens up a  list of links to other pages.

If you visit one of these pages and subsequently hit the back button you will return to a closed menu and have to reopen the list to browse for more options.

In certain circumstances this might break up the user flow somewhat. How do you keep the menu list open during the session?

This solution using the jquery cookie plugin does this very simply.

So, install jquery cookie on your server and add this snippet to your HTML: