Cookies API
cookie.get()
Gets the cookie values associated with the current document.
- Accepts arguments as strings and arrays of strings.
You can pass cookie names as individual arguments, as an array, or as a string separated by commas or spaces.
Each value is seen as a new argument. - Returns a cookie value if a single argument is passed and an object of cookie if multiple arguments or no arguments are passed.
Example:
cookie.get();
// {PHPSESSID: 'qy5f9osslggtpktf9ruoi1lp', __Secure-name: 'book', data: {book: 'name', cat: [1, 2]}}
cookie.get('data');
// {book: 'name', cat: [1, 2]}
cookie.get('name');
// 'book'
cookie.get('__Secure-name');
// 'book'
cookie.get('__Host-name');
// null
cookie.get('__Secure-name', 'data');
// {__Secure-name: 'book', data: {book: 'name', cat: [1, 2]}}
cookie.get('method', 'data');
// {method: null, data: {book: 'name', cat: [1, 2]}}
cookie.get('name', 'data');
cookie.get(['name', 'data']);
cookie.get('name, data');
cookie.get('name data');
// {name: 'book', data: {book: 'name', cat: [1, 2]}}