# Session\_id generation different for subdomains

**URL:** <https://www.ruby-forum.com/t/session-id-generation-different-for-subdomains/85340>\
**Category:** Rails\
**Created:** [February 12, 2007, 9:28pm UTC](https://www.ruby-forum.com/t/session-id-generation-different-for-subdomains/85340 "2007-02-12T21:28:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 12, 2007, 9:28pm UTC](https://www.ruby-forum.com/t/session-id-generation-different-for-subdomains/85340/1 "2007-02-12T21:28:09Z")

</div>

Hi! So, I’ve got a bunch of different subdomains for our site…

[foobar.myhost.com](http://foobar.myhost.com)  
[bar.myhost.com](http://bar.myhost.com)  
[foo.myhost.com](http://foo.myhost.com)

However, I would like for RAILS to have consistent session ids for  
each of these subdomains as they all point at the same rails  
appliation (i change behavior by adding some request headers at the  
apache end which handles directing them to the right rails  
application).

Does anybody know if there’s a patch needed, or a configuration to do  
to make rails not pay attention to the prefix of the domain name  
requested?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 12, 2007, 9:58pm UTC](https://www.ruby-forum.com/t/session-id-generation-different-for-subdomains/85340/2 "2007-02-12T21:58:11Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Hi! So, I’ve got a bunch of different subdomains for our site…
> 
> [foobar.myhost.com](http://foobar.myhost.com)  
> [bar.myhost.com](http://bar.myhost.com)  
> [foo.myhost.com](http://foo.myhost.com)
> 
> However, I would like for RAILS to have consistent session ids for  
> each of these subdomains as they all point at the same rails  
> appliation (i change behavior by adding some request headers at the  
> apache end which handles directing them to the right rails  
> application).
> 
> Does anybody know if there’s a patch needed, or a configuration to do  
> to make rails not pay attention to the prefix of the domain name  
> requested?

It may be more of a browser limitation than a rails limitation. Will  
the browser send a cookie that was set by [foo.bar.com](http://foo.bar.com) to [fab.bar.com](http://fab.bar.com)?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 12, 2007, 11:52pm UTC](https://www.ruby-forum.com/t/session-id-generation-different-for-subdomains/85340/3 "2007-02-12T23:52:27Z")

</div>

Yes, some quick digging, and you CAN set a cookie which acts over all  
subdomains.

[https://trac.cakephp.org/ticket/830](https://trac.cakephp.org/ticket/830)

Looks like this was done in cakephp… was it done in Rails?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 13, 2007, 12:30am UTC](https://www.ruby-forum.com/t/session-id-generation-different-for-subdomains/85340/4 "2007-02-13T00:30:35Z")

</div>

I guess I’ll answer my own question. But for anybody who’s wondering.  
[http://threebit.net/mail-archive/rails/msg00708.html](http://threebit.net/mail-archive/rails/msg00708.html)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 12, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/session-id-generation-different-for-subdomains/85340/5 "2007-02-12T23:21:24Z")

</div>

Excellent point…

However, I’m in control of the redirection to the new site, so I could  
just reproduce the cookie on the redirect. Or could I set a cookie  
which is good for all \*.myhost.com?
