I have a JavaScript application hosted at x.com which uses AJAX (through jQuery) to contact an Apache server hosted on the LAN environment (with a static IP, 192.168.1.5).
The Apache server exposes an API which requires the user to have a specific cookie set to use it.
My problem is that I can't get the Apache server to set a cookie with the correct domain (192.168.1.5), so that the browser sends the cookie with the AJAX call.
Is there any way to set a cookie with an IP as the domain? All examples I have seen require that the domain is of the form example.org.
The scenario is as follows:
Set-Cookie
header which should set the cookie to the 192.168.1.5 domain.Both server and client need to explicitly tell the other that they want cookies.
JavaScript
xhrInstance.withCredentials = true;
Server Header
Access-Control-Allow-Credentials: true
https://developer.mozilla.org/en-US/docs/HTTP_access_control#Requests_with_credentials
To sum it up: it has nothing to do with the IP address. The host
of the cookie can be an IP address or a domain name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With