[IOS] - Clear Cookies
mapo80 opened this issue · 6 comments
mapo80 commented
Hi,
I've a problem with method "clearCookies" on iOS if executed from the second time.
I've this error:
Error: *** __boundsFail: index 3 beyond bounds [0 .. 1]
I had to use a try/catch to intercept the error.
Do you know how to fix?
Thanks
jerbob92 commented
Hi! Are you possibly executing clearCookies 2 times at the same time? It might be some race condition, I will test this today!
mapo80 commented
No, I've seen that deleteCookie remove from array so count is different on every delete.
This should be ok:
export function clearCookies() {
if (sessionConfig.HTTPCookieStorage && sessionConfig.HTTPCookieStorage.cookies) {
const cookieSize = sessionConfig.HTTPCookieStorage.cookies.count;
if (cookieSize <= 0) {
return;
}
for (let i = cookieSize - 1; i >= 0; i--) {
const cookie = sessionConfig.HTTPCookieStorage.cookies.objectAtIndex(i);
sessionConfig.HTTPCookieStorage.deleteCookie(cookie);
}
}
}
jerbob92 commented
Ah yeah, that makes sense! I will create a new release soon, thanks!
mapo80 commented
I hope you'll create a new version soon.
Thanks very much for everything!
mapo80 commented
If you want I can make a pull request. Let me know.