Chrome localhost cookie not being set
Cookies are designed for second level and down. First level domains will not work. Instead you should use the address http://127.0.0.1 (as you mentioned) or you could edit your hosts file to map a different URL with a TLD to the address 127.0.0.1 such as:
yoursite.tld 127.0.0.1
Just researched this further; found this answer: Cookies on localhost with explicit domain
please try to put cookie.Domain = null
on localhost and use the domain name otherwise.
This was driving me nuts for hours! Then I realized:
I recently used HTTPS://localhost and set a cookie with the same name.
That was the reason HTTP://localhost was unable to set the cookie
So I went to https, cleared the cookies in the "application" tab in devtools and it started working with http again