How to remove Quicktabs cookie on certain page? I found a useful snippet here to make Quicktabs remember which tab was open if the user leaves the page and then comes back again. My problem is that I want to remove the history (the cookie) after the user has payed a visit to a certain page. In that case I want the default tab to be opened when the user comes back again. In the Quicktabs settings I have set the wanted default tab.

I have a script.js in my theme with this snippet:

  Drupal.behaviors.quicktabsHistory = {
    attach: function(context, settings) {
        var id = $(this).attr('id');
        var tab = $.cookie(id);     

        // enable quicktabs memory
        $('.quicktabs-wrapper', context).each(function() {
            if (tab != '') {
              $(this).find('ul.quicktabs-tabs a#' + tab).click();
            }
            $(this).find('ul.quicktabs-tabs a').click(function() {
                $.cookie(id, $(this).attr('id'));
            });
        });

        $('.view-taxonomy-term', context).each(function() {
            if (tab != '') {
              $.removeCookie('id');
            }
        });
    }
};


Everything works fine, except for the part where I want to loose the history. How can I remove the cookie if the user visits the page with the wrapper class ".views-taxonomy-term"?

EDITED: I tried changing the removeCookie row to insteaed force the tab I want to be the default one:

    $('.view-taxonomy-term', context).each(function() {
        if (tab != '') {
          tab = 'quicktabs-tab-instrument_flikar-0';
        }
    });


But that did not do the trick. I have checked though with a breaking point in the script that the tab variable actually is set to the new value, but the previous tab is still activated after return to the page with the tabs. There is something about Drupal.behaviors.quicktabsHistory that I don't understand, obviuosly. :-(
Finally solved it. In case anyone is stuck with the same problem, this code now works for me. I learned that it's important to always set the path, to be able to retrieve the same cookie on different pages. I never got $.removeCookie() to work, so instead I used a default value. Also it did not work to use true, false and undefined as values, but it worked to use them as text inside quotes, 'true', 'false' and 'undefined'. Slowly getting there :-).

      Drupal.behaviors.quicktabsHistory = {
        attach: function(context, settings) {       

        var default_tab = 'quicktabs-tab-instrument_flikar-0';
        if($.cookie('id', {path:'/'}) == 'undefined'){
            var id = $(this).attr('id');
        }else{
            var id = $.cookie('id', {path:'/'});
        }
        var tab = id;
        var flagga = $.cookie('flagga', {path:'/'});

        if($("body").is(".page-taxonomy")) {
            $.cookie('flagga', true, {path:'/'});
            $.cookie('id', default_tab, {path:'/'});
        }           

        $('.quicktabs-wrapper', context).each(function() {
            if (tab != '' &amp;&amp; flagga === 'false') {
              $(this).find('ul.quicktabs-tabs a#' + tab).click();
            }
            else {
              $.cookie('flagga', false, {path:'/'});                    
              $(this).find('ul.quicktabs-tabs a#' + default_tab).click();
            }

            $(this).find('ul.quicktabs-tabs a').click(function() {
                $.cookie('id', $(this).attr('id'), {path:'/'});
            });
        });
    };