Cookies get set, and are sent back, based on the domain name
of the resource that is setting the cookie.
If the page that sets the cookie was requested as:
http://www.mydomain.com/foo.cfm
then the cookie will be set on www.mydomain.com.
(Note: alternately, you can specify that you want the cookie
to be set on the domain without including the subdomain. In that
case, the cookie would be set on mydomain.com and the browser would
return that cookie for any requests to mydomain.com, or
*.mydomain.com)
If the page that sets the cookie was requested as:
http://192.168.1.1/foo.cfm
then the cookie will be set on 192.168.1.1.
Web browsers only send cookies back to servers when the
domain being requested matches one of the domains in one of the
cookies. So a subsequent request to www.mydomain.com will send the
first cookie, and a subsequent request to 192.168.1.1 will send the
second cookie.
Web browsers don't do a DNS lookup of the domain and also
send the cookies corresponding to that IP address.