Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Read Cookie Adobe Launch

1982luca
Level 8
Level 8

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
yuhuisg
Correct answer by
Community Advisor
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
yuhuisg
Correct answer by
Community Advisor
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