I can’t eat cookies localy

chris Blog , , , , ,
0

Recently I wrote some new code that utilized cookies. Not a big deal, but as I went to test the code I realized that something was not right. The code would not work. I test my code locally at first, and then when I’m assured that things are working I port it out to my development server for further testing. Now here is the kicker. The code worked on the development server, but still would not work on my local server. As I debugged the code I came to realize that the code was not reading the cookies from my local machine. OK spent some time checking out my local configuration and came to see everything was set correctly and allows cookies.

OK, long story short here. After some research I came to find out that some newer web browsers will not except cookies with out two dots in the domain field. Huh. This is now making some sense. When testing code on my local machine, I use localhost, and when testing on the development server I use development.mckinleyproducts.com.

So the question becomes how to get around this. Fortunately this is an easy fix. The easiest for my setup was just to use 127.0.0.1 instead of localhost. However there is some other options as well. Such as editing your hosts file and set a domain such as test.localhost.com to 127.0.0.1. In any case as long as there are two dots in your domain name your browser should be able to read your cookies.

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you ready to take your company to the next level?

Yes, Contact Me!