0

When I use like var values = some array which depends on the user selections.

document.cookie = "filters="+values;

How can I set the path for this cookie if the path is /abc-def/

user3686276
  • 35
  • 1
  • 8

3 Answers3

2

Try this:

document.cookie="name=value;path=/";      
CY_Techie
  • 86
  • 7
  • If i do in this way it is not storing the real value. It is storing as **"filters=value"**. I need it store as **"filters=10( value dynamically changes)"** – user3686276 Nov 27 '15 at 13:24
  • Try this : var myAry = [1, 2, 3]; $.cookie('name', JSON.stringify(myAry),path:'/'); – CY_Techie Nov 27 '15 at 13:30
1

You can use

values = JSON.stringify(values); document.cookie = "filters="+values;

ankita
  • 28
  • 4
0

This will help you more

$.cookie("test", 1, {
   expires : 10,           //expires in 10 days

   path    : '/',          //The value of the path attribute of the cookie 
                           //(default: path of page that created the cookie).    
   domain  : 'google.com',  //The value of the domain attribute of the cookie

                   //(default: domain of page that created the cookie).

   secure  : true          //If set to true the secure attribute of the cookie
                           //will be set and the cookie transmission will
                           //require a secure protocol (defaults to false).
});
Parth Trivedi
  • 3,802
  • 1
  • 20
  • 40