Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6148945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:22:09+00:00 2026-05-23T19:22:09+00:00

im using jquery cookie to pass value of the element clicked on my first

  • 0

im using jquery cookie to pass value of the element clicked on my first page to be used on the next page. The problem im experiencing is that whenever i set the cookie to null the value doesn’t delete. it still remains.

jquery script on my first page

<script>
$(document).ready(function() {
    $("div.product-header").click(function() {
        var index = $("div.product-header").index(this);
        $.cookie("product_name", index);
        //alert("product category: "+$.cookie("product_name"));
    });
    $("div.product-subheader").click(function() {
        var index = $("div.product-subheader").index(this);
        $.cookie("product_subheader", index);
        //alert("product category item: "+$.cookie("product_subheader"));
    });
});
</script>

second page script which will use the cookie (on this page the cookie is working right)

<script>
$(document).ready(function () {
    $(".product-contents").hide();
    $('div.product-header').eq($.cookie('product_name')).addClass('active').next().show(); 
    $('div.product-subheader').eq($.cookie('product_subheader')).css({fontWeight: 'bold', backgroundColor: '#eeeeee'});             
    $('div.product-header').click(function(){
       $.cookie('product_name',$('div.product-header').index(this));
        if( $(this).next().is(':hidden') ) { 
            $('div.product-header').removeClass('active').next().hide(); 
            $(this).toggleClass('active').next().show();
        }
        return false; 
    });
});
</script>

but when i try to use script on the second page; cookie doesn’t deleted whenever i used the $.cookie(“product_name”, null); and $.cookie(“product_subheader”, null); the cookie still doesn’t deleted

<script>
$(document).ready(function() {
    $("div.product-header").click(function() {
        $.cookie("product_name", null);
        alert("cookie product category should be null not: "+$.cookie("product_name"));

        var index = $("div.product-header").index(this);
        $.cookie("product_name", index);
    });

    $("div.product-subheader").click(function() {
        $.cookie("product_subheader", null);
        alert("cookie product category item should be null not: "+$.cookie("product_subheader"));   

        var index = $("div.product-subheader").index(this);
        $.cookie("product_subheader", index);
    });
});
</script>

any corrections on my code above?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:22:11+00:00Added an answer on May 23, 2026 at 7:22 pm

    You will have to specify the path when you set the cookie. Use

     $.cookie("product_name", index, { path: '/' });
    

    That should allow you to remove it from pages other than the one that created the cookie.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm using the jquery cookie plugin. Everything works fine except the fact that I
Using jquery how do I focus the first element (edit field, text area, dropdown
Using jQuery, what's the best way to find the next form element on the
How to Expire a Cookie on next visit ? I am using the jquery
I generate the jQuery cookie using this code: $.cookie('queueView', 'value', { path: '/' });
Using jQuery, is there a way to select all tag that reference a specific
Using jQuery, how do I delete all rows in a table except the first?
I am developing an application using jQuery that uses cookies. Right now, it is
I am using the jquery from https://github.com/carhartl/jquery-cookie . I am using the cookies for
I'm using the jQuery Tabs UI along with the jQuery Cookie plugin from GitHub.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.