Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Using Force Cookies Enable has problem with localhost domain


Guest

Recommended Posts

Here's some information that I though might save others some time. My apologies if there is already a thread on this. I didn't see one.

 

When I installed osc 2.2 milestone 2 and enabled "Force Cookie Use", I found that I could no longer add a product to the cart or do any of the tasks where cookie use in enforced. To troubleshoot, I did the following

I check and double checked and double checked again that my browser supported cookies.

I tried other computers with other browser versions still no luck.

I searched the forum and saw lots of happy people using this feature, so I figured it had to be my problem.

I saw some forum posts from May and June that started to shed some light on the problem, but still no solution.

Then I searched the php manuel, and in the comments of setcookie page

(http://us4.php.net/manual/en/function.setcookie.php), I found this:

When developing web applications on your local machine and using "localhost" as your domain, cookies will not be set correctly using IE6 (maybe other IEs as well) if you specify "localhost" as your domain when using setCookie(). If you read the Netscape spec, there is a note:

 

Bingo! On my development server, I don't set HTTP_SERVER to http://localhost, but I do set it to http://mycomputername. From what I've read, some browsers require the domain name used in cookies to have either 2 or 3 . (dots) in it. This means setting HTTP_SERVER to localhost won't work. However using the IP address will.

 

Unfortunately, I wasted some more time here, because in my haste to test I changed HTTP_SERVER, but I forgot to also change HTTP_COOKIE_DOMAIN.

 

So to summarize, if you're using Force Cookies Enabled and your sites not working even though you're sure cookies are enabled, then if you have the a domain with less than 2 . (dots) in it. For example:

 

define('HTTP_SERVER', 'http://localhost');

define('HTTP_COOKIE_DOMAIN', 'localhost');

 

then try changing to your ip address or some other domain with 2 or more . (dots). For example:

 

define('HTTP_SERVER', 'http://192.168.1.100');

define('HTTP_COOKIE_DOMAIN', '192.168.1.100');

 

Hope this helps,

-Chandra

Link to comment
Share on other sites

  • 4 months later...
  • 2 years later...
  • 2 years later...
  • 1 year later...

This

define('HTTP_COOKIE_DOMAIN', '192.168.1.100');

should be

define('HTTP_COOKIE_DOMAIN', '.192.168.1.100');

 

Force Cookies should never be used, in my opinion.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 1 year later...

I'm having a similar issue with my website.

 

I enabled cookie use from admin page, but now when I go back to admin page, I can't seem to log back in to do anything. It just redirects me to the admin login page again.

 

Could someone help please ?

 

Is there a way to turn off force cookie use manually? (through database, etc...)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...