I have a question exactly the same as the question here, but I use react-native and my string was saved on my local device came from axios
header like this
cAxios.interceptors.response.use(
async function (response) {
const cookieHeaders = response.headers['set-cookie']
await storeData('cookie', cookieHeaders)
// code here...
return response
},
function (error) {
// code here...
}
);
That means that I cant use the Headers
Constructor as the accepted answer says.
I have a sting like this
cookie1=value, cookie2=value2; Expires=Thu, 06 Jul 2023 14:45:25 GMT; path=value5, express-token=value; path=value
same as the question mentioned, if I do string.split(', ')
my string is split in 4:
- cookie1=value
- cookie2=value2; Expires=Thu
- 06 Jul 2023 14:45:25 GMT; path=value5
- express-token=value; path=value
While here is my expected result:
- cookie1=value
- cookie2=value2; Expires=Thu, 06 Jul 2023 14:45:25 GMT; path=value5
- express-token=value; path=value
is there a way to parse this to get the correct cookie values?