Reputation: 81
It's possible to clear react-native webview cookie? when I replace to other view and back and mount webview again, it looks like the cookie still exist in the webview..
greetings
Upvotes: 8
Views: 5965
Reputation: 867
You can use react-native-cookies to manage your app cookies.
import CookieManager from 'react-native-cookies';
// clear cookies on webview will mount!
CookieManager.clearAll()
.then((res) => {
console.log('CookieManager.clearAll =>', res);
});
Upvotes: 2
Reputation: 842
You can use AsyncStorage which comes with react-native
import { AsyncStorage } from 'react-native'
AsyncStorage.setItem('token', user.token)
AsyncStorage.removeItem('token')
AsyncStorage.getItem('token', (ignore, result) => {})
Just be careful the getItem is a promise based functionality.
Then on component load check create an action/function that checks if the user has the authorization for it based on the above!
Upvotes: -1