I have a json object data like this and I want to set it as cookie:
I convert the this object to string via JSON.stringify(). And then when I want to set that new string text as Cookie to my Cookies area , setting processing does not work. I mean I can not write it as cookie value. I think there is an error during stringify. What is your solutions? Do you have any recommend me to set it as cookie value?
Pure data :
{"alias":"TestName","name":"Test","image":"sadasdasd3213","modules":["Community","InternalCommunication","Interest","Event","SelfService","FileSharing","SkillSet"],"id":2,"userAgreements":[{"id":"BA3909CC-2393-4CB9-AA52-178E2001A06B","url":"https://www.google.com.tr/docs/abcd.pdf","displayName":"Çerez Aydınlatma Metni"},{"id":"834657C3-0802-471C-8699-41A4D76977FA","url":"https://www.google.com.tr/docs/abcd.pdf","displayName":"Üyelik Sözleşmesi ve Kullanım Koşulları"},{"id":"27F11B55-4427-4C66-953C-70627E781B09","url":"https://www.google.com.tr/docs/abcd.pdf","displayName":"Aydınlatma Metni"}],"isConnectedToSso":true,"alertCount":0,"portal":{"portalLogo":"21321asfdasf3","id":3,"companyId":2,"portalName":"LIFE","portalLink":"https://www.google.com.tr/"},"isOtpProcess":true,"fontColor":"313384","backgroundColor":"313384","surveyLastDayValue":7}
example code :
const testData = JSON.stringify(response.singleData)
localStorage.setItem("alias", JSON.stringify(response.singleData)); // it works as local storage data
Cookies.set('czn', JSON.stringify({data : response.singleData}) , { expires: 1 }) // js-cookie package , it does not work
setCookie('alias', testData,{ path: '/' }); // react-cookie package, it does not work