# How can I read a cookie set on another subdomain by a non-Rails app?

**URL:** <https://www.ruby-forum.com/t/how-can-i-read-a-cookie-set-on-another-subdomain-by-a-non-rails-app/168577>\
**Category:** Rails\
**Created:** [May 22, 2009, 4:25pm UTC](https://www.ruby-forum.com/t/how-can-i-read-a-cookie-set-on-another-subdomain-by-a-non-rails-app/168577 "2009-05-22T16:25:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [May 22, 2009, 4:25pm UTC](https://www.ruby-forum.com/t/how-can-i-read-a-cookie-set-on-another-subdomain-by-a-non-rails-app/168577/1 "2009-05-22T16:25:26Z")

</div>

I’m trying to build some single sign on functionality into our web  
application.

There’s community site on a subdomain: i.e. [community.domain.com](http://community.domain.com)

The Rails app is on: [www.domain.com](http://www.domain.com)

When I inspect the cookies, I don’t see any of the  
“[community.domain.com](http://community.domain.com)” cookies.

In “production.rb”, I have this:  
ActionController::CgiRequest::DEFAULT\_SESSION\_OPTIONS.update  
(:session\_domain =\> ‘.domain.com’)

That doesn’t seem to help.

How can I get my “www” app to read from the “community” subdomain?

Thanks,  
Andy

---

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [May 22, 2009, 4:37pm UTC](https://www.ruby-forum.com/t/how-can-i-read-a-cookie-set-on-another-subdomain-by-a-non-rails-app/168577/2 "2009-05-22T16:37:46Z")

</div>

On May 22, 3:24 pm, Andy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In “production.rb”, I have this:  
> ActionController::CgiRequest::DEFAULT\_SESSION\_OPTIONS.update  
> (:session\_domain =\> ‘.domain.com’)
> 
> That doesn’t seem to help.
> 
> How can I get my “www” app to read from the “community” subdomain?

what is the app setting the cookies doing ? if it’s setting them for  
[community.domain.com](http://community.domain.com) rather than .domain.com then you can’t get them  
because the browser won’t be sending them

Fred

---

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [May 22, 2009, 5:02pm UTC](https://www.ruby-forum.com/t/how-can-i-read-a-cookie-set-on-another-subdomain-by-a-non-rails-app/168577/3 "2009-05-22T17:02:56Z")

</div>

I have no control over what the “[community.domain.com](http://community.domain.com)” server does.  
It’s a hosted application.

So you’re saying that the browser won’t be sending cookies from  
“[community.domain.com](http://community.domain.com)” for use on other subdomains?

Thanks,  
Andy

On May 22, 10:37 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [May 22, 2009, 5:40pm UTC](https://www.ruby-forum.com/t/how-can-i-read-a-cookie-set-on-another-subdomain-by-a-non-rails-app/168577/4 "2009-05-22T17:40:31Z")

</div>

On May 22, 4:01 pm, Andy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have no control over what the “[community.domain.com](http://community.domain.com)” server does.  
> It’s a hosted application.
> 
> So you’re saying that the browser won’t be sending cookies from  
> “[community.domain.com](http://community.domain.com)” for use on other subdomains?

correct (see [RFC 2965 - HTTP State Management Mechanism](http://tools.ietf.org/html/rfc2965) ) (unless the  
subdomain was [something.community.domain.com](http://something.community.domain.com))

Fred
