# Session sharing between domains

**URL:** <https://www.ruby-forum.com/t/session-sharing-between-domains/181541>\
**Category:** Rails\
**Created:** [January 13, 2010, 2:00pm UTC](https://www.ruby-forum.com/t/session-sharing-between-domains/181541 "2010-01-13T14:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![icke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e19adc/32.png) [@icke](https://www.ruby-forum.com/u/icke)\
**Post date:** [January 13, 2010, 2:00pm UTC](https://www.ruby-forum.com/t/session-sharing-between-domains/181541/1 "2010-01-13T14:00:00Z")

</div>

I collect some stuff in my application session. I then need to  
redirect to another domain(not subdomain) run by the same ruby  
application instance (as it needs to be an SSL certificate domain). I  
can rebuild my application session bit by bit but it would be DRYer if  
I pass the session\_id into the SSL domain as a param on the redirect  
and then “switch the session” to the new domain by invoking a  
before\_filter on the SSL protected actions to pull the correct  
session. Set the new cookie and so forth

Anyone any ideas on how to do this or is there already a plugin to do  
this?

Cheers.

O.

---

<div class="post-metadata">

**Author:** ![icke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e19adc/32.png) [@icke](https://www.ruby-forum.com/u/icke)\
**Post date:** [January 14, 2010, 5:37am UTC](https://www.ruby-forum.com/t/session-sharing-between-domains/181541/2 "2010-01-14T05:37:12Z")

</div>

On Jan 13, 5:58Â am, icke [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> this?  
> You could use single\_access\_token (API Key) with Authlogic.

Also, if you can get you users to use Chrome or Firefox or Safari you  
can use XHR2 / CORS and set withCredentials = 2 and pass the cookie to  
the non-origin domain (this also requires setting some headers and  
enabling support for OPTIONS).

If that’s what you think you’re looking for and you’d like me to  
detail it a little better I will.

AJ ONeal

---

<div class="post-metadata">

**Author:** ![icke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e19adc/32.png) [@icke](https://www.ruby-forum.com/u/icke)\
**Post date:** [January 14, 2010, 5:45am UTC](https://www.ruby-forum.com/t/session-sharing-between-domains/181541/3 "2010-01-14T05:45:59Z")

</div>

typo:  
withCredentials = true

AJ ONeal
