Cookies passed in custom header not working
See original GitHub issueBug description: I am trying to pass a cookie via a custom header, but it does not seem to work at all. My site looks for a specific cookie on certain pages and it doesn’t seem to find it. I have also tried a super simple test example, exactly like the documentation, except the url is hitting a test page on a local server that creates an alert with all cookies. The documentation I am following is here: https://github.com/react-native-community/react-native-webview/blob/master/docs/Guide.md#working-with-custom-headers-sessions-and-cookies
Am I missing something???
To Reproduce:
- Spin up a local web server with a simple web page that uses JS to show an alert with all the document’s cookies. JS example:
<script type="text/javascript">
alert('document.cookie='+document.cookie);
</script>
- Create a simple RN app with the latest react-native-webview module, and add the following code:
const App = () => {
return (
<WebView
source={{
uri: 'http://localhost:8083', // location of the web page of step 1
headers: {
Cookie: 'cookie1=asdf; cookie2=dfasdfdas',
},
}}
sharedCookiesEnabled={true}
/>
);
};
- Notice that none of the cookies set in the custom header are not found.
Expected behavior: Cookies passed in a custom header can be read by the receiving web page.
Environment:
- OS: macOS Catalina
- OS version: 10.15.4
- react-native version: 0.62.2
- react-native-webview version: 9.4.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:11
Top Results From Across the Web
7 Keys to the Mystery of a Missing Cookie - Medium
Troubleshooting tip: open the developer console and check in the Network tab what are the response headers from OPTIONS . Solution tip: On...
Read more >set-cookie header not working - Stack Overflow
I found here that my Set-Cookie header was not accessible to my client unless I added it to the exposed-header header. Hope this...
Read more >Logic Apps custom connector with Cookie header
Hi,. I am trying to call an api through a custom connector (Gateway enabled) through a logic app. There are 2 custom connectors....
Read more >HTTP headers - MDN Web Docs - Mozilla
HTTP headers let the client and the server pass additional information with an HTTP ... General warning information about possible problems.
Read more >Setting and modifying Headers and Cookies - Twilio
The Response object exposes the following methods to allow you to customize what headers are sent in response to incoming requests. Headers. setHeaders() ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same for me, the cookies are not passed except with incognito=true … Has anyone found a solution?
I’ve also found this, but only on Android, iOS works fine. Adding incognito mode made Android work, but sadly I can’t use incognito mode for other reasons. Interestingly it only seems to happen the first time I open the webview, subsequent times it is receiving the cookies for me.