Cookie Collapse
HTML
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/js/bootstrap-collapse.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/css/bootstrap-combined.min.css">
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/js/bootstrap-transition.js"></script>
<button class="btn btn-danger" data-toggle="collapse" data-target="#demo">simple collapsible</button>
<div id="demo" class="collapse in">
<img src="//placehold.it/400x200">
</div>
JavaScript
var c = document.cookie;
$('.collapse').each(function () {
if (this.id) {
var pos = c.indexOf(this.id + "_collapse_in=");
if (pos > -1) {
c.substr(pos).split('=')[1].indexOf('false') ? $(this).addClass('in') : $(this).removeClass('in');
}
}
}).on('hidden shown', function () {
if (this.id) {
document.cookie = this.id + "_collapse_in=" + $(this).hasClass('in');
}
});