I have added this script in my Drupal 7 site to make the site remember the last clicked Quicktab and then open that tab on page reload:
// JavaScript Document
(function($) {
Drupal.behaviors.quicktabsTabMemory = {
attach: function(context, settings) {
// The .each() is in case there is more than one quicktab on a page.
$('.quicktabs-wrapper', context).each(function () {
var $this = $(this);
var wrapperID = $this.attr('id');
var nid = settings.nordtec_klister['currentNid']; // getting the nid on the client side
var $activeTabLink = $('.quicktabs-tabs li.active a', context);
var activeTabLinkID = $activeTabLink.attr('id');
// Use a unique cookie namespace for each set of Quicktabs, which
// should allow for more than one set on a page.
var cookieName = 'Drupal-quicktabs-active-tab-id-' + wrapperID + 'nid='+ nid;
// Default cookie options.
var cookieOptions = {path: '/'};
// Click the tab ID if a cookie exists otherwise set a cookie for
// the default active tab.
var $cookieValue = $.cookie(cookieName);
if ($cookieValue) {
$('#' + $cookieValue).click();
}
else {
$.cookie(cookieName, activeTabLinkID, cookieOptions);
}
// Set the click handler for all tabs, this updates the cookie on every
// tab click.
$this.find('ul.quicktabs-tabs a').click(function quicktabsCookieClickHandler() {
$activeTabLink = $this.find('.quicktabs-tabs li.active a', context);
activeTabLinkID = $activeTabLink.attr('id');
$.cookie(cookieName, activeTabLinkID, cookieOptions);
});
});
}
};
})(jQuery);
This works as a charm, BUT ever since I added this I keep getting this message in the browser (Chrome)...
Bad Request Your browser sent a request that this server could not understand. Size of a request header field exceeds server limit.
...after maybe 1 or 2 working days of browsing the site, adding and editing content (many tabs open with different pages etc). I can only assume that it's not a coincidence that those error messages began to show soon after I added this script.
So my question is: What should I do in order to avoid those messages? Clear out all cookies after a certain time? I have tried to limit the cookie life time to 28800 seconds and also the garbage collector life time to that same value in settings.php:
ini_set('session.gc_maxlifetime', 28800);
ini_set('session.cookie_lifetime', 28800);
This helped some, the messages does not occur as often after this, but they do still happen once a week or so.