# Maintaining session data across multiple domains

**URL:** <https://www.ruby-forum.com/t/maintaining-session-data-across-multiple-domains/161574>\
**Category:** Rails\
**Created:** [February 27, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/maintaining-session-data-across-multiple-domains/161574 "2009-02-27T15:25:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [February 27, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/maintaining-session-data-across-multiple-domains/161574/1 "2009-02-27T15:25:36Z")

</div>

I’m working on an application that can be accessed from multiple  
domains. I want to maintain session data across these domains, such  
that if a user logs in at [www.domain1.com](http://www.domain1.com), then moves to  
[www.domain2.com](http://www.domain2.com),  
they will still be logged in with the same account. Is this possible  
in Rails? Could anyone point me towards a guide of how to achieve it?

Many thanks,  
Adam

---

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [February 27, 2009, 6:11pm UTC](https://www.ruby-forum.com/t/maintaining-session-data-across-multiple-domains/161574/2 "2009-02-27T18:11:09Z")

</div>

On 27 Feb 2009, at 14:24, Adam wrote:

> I’m working on an application that can be accessed from multiple  
> domains. I want to maintain session data across these domains, such  
> that if a user logs in at [www.domain1.com](http://www.domain1.com), then moves to [www.domain2.com](http://www.domain2.com)  
> ,  
> they will still be logged in with the same account. Is this possible  
> in Rails? Could anyone point me towards a guide of how to achieve it?

Well you will definitely need to move away from the cookie store.  
I imagine you could do something like redirect users with no session  
to [blah.domain.com](http://blah.domain.com) - this creates/looks up their session id. Then it  
redirects them back to the original domain along with a token telling  
that app what the session id of the user should be (so that this app  
can set the cookie saying what the session id is)

Fred
