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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:39:44+00:00 2026-06-12T11:39:44+00:00

i searched around stackoverflow and found out that cookie only can store string not

  • 0

i searched around stackoverflow and found out that cookie only can store string not array.

i have an array like this:

  var myvar = {
   'comment' : '123',
   'blog' : 'blog',
   'test' : '321
  }

Then i use this jquery plugin to manage the cookies:
https://github.com/carhartl/jquery-cookie/blob/master/jquery.cookie.js

I use the below code to store the cookie named ‘setting’:

  $.cookie('setting',  myvar , { expires: 1, path: '/' });

However how do i convert that array into a string , i know i can use .join , but what if my array values for example comment , is a special character like Chinese characters etc.

and how can i access the cookie again and get the string out and convert it again into an array?

  • 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-12T11:39:45+00:00Added an answer on June 12, 2026 at 11:39 am

    To store an object in a cookie:

    var myvar = {
       'comment' : '123',
       'blog' : 'blog',
       'test' : '321'
    };
    
    var serialized = JSON.stringify(myvar);
    
    $.cookie('setting', serialized, { expires: 1, path: '/' });
    

    To retrieve an object from a cookie :

    JSON.parse($.cookie("setting"));
    

    See this answer for examples of JSON.stringify and JSON.parse.

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

Sidebar

Related Questions

I searched around the webs and found tools that can indent java,C,php,HTML etc. Is
I have searched around Google and StackOverflow trying to find a solution to this,
I have searched around and have not been able to find a solution for
I've searched around but I can't find any information about this; maybe I'm not
I searched around for a basic WYSIWYG rich text editor that I can use
I've searched around, and there are responses to whether a Drupal term can have
Searched around a bit, found different tools to check weak ciphers. How can I
I searched around for a while and only came up wit solutions that added
I have searched around, and it seems that this is a limitation in MS
I've searched around a bit, but haven't found a satisfactory answer, so I'd like

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.