So there's a very simple example in the documentation that shows how you can pass cookies to a Webview:
const App = () => {
return (
<WebView
source={{
uri: 'http://example.com',
headers: {
Cookie: 'cookie1=asdf; cookie2=fdsa; cookie3=aaaa',
},
}}
/>
);
};
How can I pass some attributes to each cookie?
If I open the Console in Google Chrome I can paste the following:
document.cookie ='cookie1=asdf;domain=.mydomain.com;path=/;'
document.cookie ='cookie2=fdsa;domain=.mydomain.com;path=/;'
document.cookie ='cookie3=aaaa;domain=.mydomain.com;path=/;'
This sets 3 cookies in the browser. Which is cool. If I try in React Native
const App = () => {
return (
<WebView
source={{
uri: 'http://example.com',
headers: {
Cookie: 'cookie1=asdf;domain=.mydomain.com;path=/;cookie2=fdsa;domain=.mydomain.com;path=/;cookie3=aaaa;domain=.mydomain.com;path=/;',
},
}}
/>
);
};
this will probably set 5 different cookies in the WebView: cookie1, cookie2, cookie3, domain, path