import Cookies from 'universal-cookie';
const cookies = new Cookies();
cookies.remove('abc');
console.log(cookies.getAll());
It is still printing my abc
cookie.
Cookies can be removed in React. js by using the following methods: By using cookies. remove() in the react-cookie library.
By default, when you fetch your URL, React native sets the cookie. To see cookies and make sure that you can use the https://www.npmjs.com/package/react-native-cookie package.
In this example, I will use axios to make such API call in the frontend. Note that every API call's request header will contain our httpOnly cookie and it's content - we can confirm this by opening chrome dev tools' network tab, make the API call, then check the "Request Headers" for the "Cookie"...
Cookies need to have both path and domain appended to them to be removed. Try this:
cookies.remove("abc", {path: "/", domain: ".example.com"})
May be you need to do something like
cookies.remove('abc', { path: '/' });
More info here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With