Can not get the cookies from localhost

Summary.

## Expected Result

```
>>>import requests
>>>requests.get('http://localhost/test.php').cookies
<RequestsCookieJar[Cookie(....)]>
```

## Actual Result

```
>>>import requests
>>>requests.get('http://localhost/test.php').cookies
<RequestsCookieJar[]>
```

## Reproduction Steps

```python
import requests
requests.get('http://localhost/test.php').cookies
```

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.6"
  },
  "implementation": {
    "name": "CPython",
    "version": "2.7.14"
  },
  "platform": {
    "release": "7",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.18.4"
  },
  "system_ssl": {
    "version": "100020bf"
  },
  "urllib3": {
    "version": "1.22"
  },
  "using_pyopenssl": false
}
```

This command is only available on Requests v2.16.4 and greater. Otherwise,
please provide some basic information about your system (Python version,
operating system, &c).
----  

### I found it when I test a php script.I put it on IIS and explorer worked.Howerver requests did not got the cookies,response header showed there was a key "Set-Cookie".Strangely,when I put the php script on my site whose domain is not localhost,requests successfully got the cookies.  
### The session is the same situation.
### Sorry for my poor English.

Hi @MrThanlon, can you please show us the value of `history` on the `Response` object? 

Hi again @MrThanlon, here's a simple POC showing that cookies work fine on localhost. It looks like your IIS instance is doing some kind of redirect which is affecting the cookies on the response object. I'm closing this out since things are working as expected. Thanks again for the report though!


```python
import pytest
import threading
import requests

from tests.testserver.server import Server, consume_socket_content

def test_cookie_set_for_localhost():

    def response_handler(sock):
        consume_socket_content(sock, timeout=0.5)
        sock.send(
            b'HTTP/1.1 200 OK\r\n'
            b'Content-Length: 0\r\n'
            b'Set-Cookie: foo=bar; Max-Age=86400; Secure; HttpOnly\r\n\r\n'
        )

    close_server = threading.Event()
    server = Server(response_handler, wait_to_close_event=close_server)

    with server as (host, port):
        url = 'http://{0}:{1}/'.format(host, port)
        r = requests.get(url)

        assert r.status_code == 200

        # Verify we received our expected cookie
        assert r.cookies
        assert r.cookies.get('foo') == 'bar'

        close_server.set()
```

I can still reproduce this. Just like OP, I am using PHP on the server. I can confirm that requests does not see cookies for PHP app running on localhost but it does for the same app running on production server, even though the `r.headers['Set-Cookie']` header is basically identical (modulo the `Domain` key).

In fact, I can reproduce it in @nateprewitt’s example if I add the `Domain` tag (with `requests` d3e0f73354051f824cae563aeae215006158da28):

```python
import pytest
import threading
import requests

from tests.testserver.server import Server, consume_socket_content

def test_cookie_set_for_localhost():

    def response_handler(sock):
        consume_socket_content(sock, timeout=0.5)
        host, port = sock.getsockname()
        sock.send(
            b'HTTP/1.1 200 OK\r\n'
            b'Content-Length: 0\r\n'
            b'Set-Cookie: foo=bar;   Max-Age=86400; Domain=localhost; Secure; HttpOnly\r\n\r\n'
            # b'Set-Cookie: foo=bar; Max-Age=86400; Domain=localhost:' + str(port).encode('ascii') + b'; Secure; HttpOnly\r\n\r\n' # does not help
        )

    close_server = threading.Event()
    server = Server(response_handler, wait_to_close_event=close_server)

    with server as (host, port):
        url = 'http://{0}:{1}/'.format(host, port)
        r = requests.get(url)

        assert r.status_code == 200

        print(host, port)

        # Verify we received our expected cookie
        assert r.cookies
        assert r.cookies.get('foo') == 'bar'

        close_server.set()
```