# Sessions across subdomains

**URL:** <https://www.ruby-forum.com/t/sessions-across-subdomains/121413>\
**Category:** Rails\
**Created:** [November 27, 2007, 7:35pm UTC](https://www.ruby-forum.com/t/sessions-across-subdomains/121413 "2007-11-27T19:35:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dougal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@dougal](https://www.ruby-forum.com/u/dougal)\
**Post date:** [November 27, 2007, 7:35pm UTC](https://www.ruby-forum.com/t/sessions-across-subdomains/121413/1 "2007-11-27T19:35:52Z")

</div>

Hi Folks.

I have an application that is accessed from a domain, and a subdomain  
of the same domain dependent on scope.

[example.com](http://example.com)  
[subdomain.example.com](http://subdomain.example.com)

How do I ensure that a session remains valid (stays logged in) when the  
user passes between these?

I’ve done a google for this, but so far come up blank.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dougal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@dougal](https://www.ruby-forum.com/u/dougal)\
**Post date:** [November 27, 2007, 8:25pm UTC](https://www.ruby-forum.com/t/sessions-across-subdomains/121413/2 "2007-11-27T20:25:52Z")

</div>

On Nov 27, 2007 12:35 PM, Douglas S.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have an application that is accessed from a domain, and a subdomain  
> of the same domain dependent on scope.
> 
> [example.com](http://example.com)  
> [subdomain.example.com](http://subdomain.example.com)
> 
> How do I ensure that a session remains valid (stays logged in) when the  
> user passes between these?

You have to change the cookie domain:

[http://wiki.rubyonrails.com/rails/pages/HowtoChangeSessionOptions](http://wiki.rubyonrails.com/rails/pages/HowtoChangeSessionOptions)

Scroll to the bottom.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)
