Expand my Community achievements bar.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

Read Cookie Adobe Launch

Avatar

Level 9

Hello everyone,

 

I am setting a cookie with _satellite.cookie.set(digitalData,digitalData); Basically I am thinking of storing the digitalData in th cookie, ONLY for authenticated users and re-use it where I need, by using _satellite.cookie.get. My question is, how to read the digitalData json ? For instance, how can i read  digitalData.user.customerId from the json cookie?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Cookie values can only be strings. I haven't personally tried storing non-text values in cookies using _satellite.cookie.set(), but if it's working for you, then that means Launch is able to stringify the object before storing it as a JSON value in the cookie.

_satellite.cookie.get() would return the cookie's value as-is, i.e. as a string. To convert it back to its original type, use `JSON.parse()`.

E.g.

var digitalDataString = _satellite.cookie.get("digitalData");
var digitalData = JSON.parse(digitalDataString); // this is what you want
// you should now be able to get digitalData.customerId

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Cookie values can only be strings. I haven't personally tried storing non-text values in cookies using _satellite.cookie.set(), but if it's working for you, then that means Launch is able to stringify the object before storing it as a JSON value in the cookie.

_satellite.cookie.get() would return the cookie's value as-is, i.e. as a string. To convert it back to its original type, use `JSON.parse()`.

E.g.

var digitalDataString = _satellite.cookie.get("digitalData");
var digitalData = JSON.parse(digitalDataString); // this is what you want
// you should now be able to get digitalData.customerId