[Question] clearByName Android alternative?
Hello!
I am looking to be able to clear all Cookies for a specific Domain and can see that clearByName is only supported for IOS.
e.g docs
// clear cookies with name (IOS ONLY)
CookieManager.clearByName('http://example.com', 'cookie name', useWebKit)
.then((succcess) => {
console.log('CookieManager.clearByName from webkit-view =>', succcess);
});
Has anyone found a way to do this with Android?
Thank you Francis
Thinking this package could be a viable alternative to this library.
Need this property for the android platform. I don't want to clearAll cookies
Yeah Android doesn't support this out of the box https://developer.android.com/reference/android/webkit/CookieManager, hence only supporting iOS.
Open to seeing how we could design this feature since its been highly requested.
Any update on this issue?
I'd love to know how to clear cookies for a certain URL on android
Ok, so what works for me is simply setting the value of the cookie I want to delete to an empty string.
But I honestly have no clue why the token gets automatically deleted when I set the value to an empty string.
Can anyone else try this out and confirm this?
@safaiyeh
CookieManager.set(<url>, { name: "<cookieName>", value: ""})
Edit. In RFC 6265 it also says that in order to delete cookies, servers can simply send a cookie with the same value but an expiry date in the past. Maybe that's what's happening here? Either way that also seems like a good way to delete a single cookie 4.1.2
Notice that servers can delete cookies by sending the user agent a new cookie with an Expires attribute with a value in the past.
Edit2. Did another test. This deletes the cookie with the value of cookieName:
CookieManager.set(url, {
name: cookieName,
value: '',
expires: '2024-05-30T12:30:00.00-05:00',
})
obviously the expiry date is not needed for the deletion here