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 8510903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:50:10+00:00 2026-06-11T03:50:10+00:00

I was wondering if it was possible whether jquery can check if a cookie

  • 0

I was wondering if it was possible whether jquery can check if a cookie array exists or not.

My cookie name is ‘report’ and with php I echo it out like this:

echo '<pre>'; print_r($_COOKIE['report'][146]); echo '</pre>';

Which spits out something like this:

Array
(
    [15128] => 15128
    [13670] => 13670
)

This is where I’m hoping to get jquery to check if the above cookie array exists (or not), this is what I’ve got so far, but it’s not picking up the cookie array..

if ( $.cookie('report[146]') ) {
  window.location = 'http://www.myurl.com/';
} else {
  alert('Please make a selection.');
}

My form doesn’t refresh when someone ticks a checkbox, but it uses jquery to add the cookie (which works fine), but I can’t seem to get jquery to check if there are any cookies.

This is the code where it adds individual cookies to the array:

if ($(this).attr('checked')) { 
  $.cookie('report[146]['+thisID+']', thisID, { expires: 7, path: '/' });
} else {
  $.cookie('report[146]['+thisID+']', thisID, { expires: -1, path: '/' });
};

Any help would be appreciated!

  • 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-06-11T03:50:12+00:00Added an answer on June 11, 2026 at 3:50 am

    What you’re doing right now is setting cookie that is named report[146]['+thisID+'] (if for example thisID = 135, then cookie name is report[146][135]). Value of the cookie is not an array, the value of that cookie is value of thisID.

    If you want cookie to have name report and it’s value should be array that at index 146 has value thisID, do the following:

    var cookieValue = [];
    cookieValue[146] = thisID;
    

    set it:

    $.cookie('report', cookieValue);
    

    Cookie value will now be set to (that’s the way array is serialized):

    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,135
    

    To read it:

    var cookie = $.cookie('report');
    if(cookie){
      var cookieValue = cookie.split(','); //you need to do this since array is serialized as comma separated values.
      var valueAtIndex146 = cookieValue[146];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering whether or not it is possible to output the class name
I am wondering whether or not it is possible to elegantly map the results
i was wondering whether it was possible for jquery to make a text field
I was wondering if it is possible to detect whether or not my Android
I was wondering if it is possible to check whether there is an instance
I am just wondering whether or not it is possible to shift a UITableView
I was wondering if this is at all possible, I want to check whether
I am wondering if it is possible to detect whether the user exits the
I was wondering whether it is possible to limit the number of characters we
I am wondering whether it is possible to make dynamic variables in Java. In

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.