2

I am trying to coordinate cookies that were set by setcookie in PHP with cookie in Rails. The problem is when I set the cookie to localhost domain in PHP with COOKIE_DOMAIN false it sets it to domain 127.0.0.1. However Rails settings to localhost domain instead of 127.0.0.1 domain uses localhost. Therefore I have two different domains (127.0.0.1 and localhost) to localhost domain. How can I fix it, to set the cookie explicitly to localhost domain with setcookie.

Thanks!

2
  • 1
    What URL are your PHP and rails applications running on, respectively? Commented Dec 27, 2011 at 9:29
  • @Pekka, you was right, it was so simple, it's difference in paths ;) Commented Dec 27, 2011 at 9:38

2 Answers 2

2

The cookie's domain depends on the current domain when the cookie is set. Make sure both your applications are pointing to localhost - then it should work.

Sign up to request clarification or add additional context in comments.

Comments

0

bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] )

You need to set $domain manually to 'localhost'

2 Comments

Have you tried this? I don't think it will work. You can't set cookies to belong to other domains like that
You can set a domain e.g. to '.domain.com' to also match subdomains, so it's just a thought. haven't actally tried it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.