# Authentication cookies

**URL:** <https://www.ruby-forum.com/t/authentication-cookies/196728>\
**Category:** Rails\
**Created:** [June 26, 2008, 11:50pm UTC](https://www.ruby-forum.com/t/authentication-cookies/196728 "2008-06-26T23:50:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![staypufd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@staypufd](https://www.ruby-forum.com/u/staypufd)\
**Post date:** [June 26, 2008, 11:50pm UTC](https://www.ruby-forum.com/t/authentication-cookies/196728/1 "2008-06-26T23:50:04Z")

</div>

I would like to know if it is possible to share Authentication cookies  
between 2 url’s with ruby. Does anyone know how to?

thanks

---

<div class="post-metadata">

**Author:** ![staypufd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@staypufd](https://www.ruby-forum.com/u/staypufd)\
**Post date:** [June 27, 2008, 9:58am UTC](https://www.ruby-forum.com/t/authentication-cookies/196728/2 "2008-06-27T09:58:57Z")

</div>

On Jun 26, 10:50 pm, Sam G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I would like to know if it is possible to share Authentication cookies  
> between 2 url’s with ruby. Does anyone know how to?

Well for starters the contents of the authentication cookie needs to  
contain something the 2 apps understand (assuming it’s two different  
apps), so for example just sticking user.id in the cookie won’t be  
enough if user ids don’t match between the 2 apps.  
Secondly you’ll have to set the domain of the cookie appropriately.  
Normally if you go to [foo.bar.com](http://foo.bar.com) you’ll get a cookie valid for  
[foo.bar.com](http://foo.bar.com). Instead you need to set the domain of the cookie to  
‘.bar.com’ which means that anything ending in [bar.com](http://bar.com) will receive  
your cookie

Fred

---

<div class="post-metadata">

**Author:** ![staypufd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@staypufd](https://www.ruby-forum.com/u/staypufd)\
**Post date:** [June 27, 2008, 1:06pm UTC](https://www.ruby-forum.com/t/authentication-cookies/196728/3 "2008-06-27T13:06:17Z")

</div>

> Well for starters the contents of the authentication cookie needs to  
> contain something the 2 apps understand (assuming it’s two different  
> apps), so for example just sticking user.id in the cookie won’t be  
> enough if user ids don’t match between the 2 apps.  
> Secondly you’ll have to set the domain of the cookie appropriately.  
> Normally if you go to [foo.bar.com](http://foo.bar.com) you’ll get a cookie valid for  
> [foo.bar.com](http://foo.bar.com). Instead you need to set the domain of the cookie to  
> ‘.bar.com’ which means that anything ending in [bar.com](http://bar.com) will receive  
> your cookie
> 
> Fred

I forgot to mention that the 2 URL’s are completely different but they  
are using the same database. I’m not sure if this is possible two write  
one cookie that checks authentication for both sites. If this does not  
work is there any other way I can do this?

thanks

---

<div class="post-metadata">

**Author:** ![staypufd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@staypufd](https://www.ruby-forum.com/u/staypufd)\
**Post date:** [June 27, 2008, 1:10pm UTC](https://www.ruby-forum.com/t/authentication-cookies/196728/4 "2008-06-27T13:10:34Z")

</div>

On 27 Jun 2008, at 12:06, Sam G. wrote:

> > your cookie
> > 
> > Fred
> 
> I forgot to mention that the 2 URL’s are completely different but  
> they  
> are using the same database. I’m not sure if this is possible two  
> write  
> one cookie that checks authentication for both sites. If this does not  
> work is there any other way I can do this?

In that case you can’t share a cookie. Have you considered OpenID ?

Fred

---

<div class="post-metadata">

**Author:** ![staypufd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@staypufd](https://www.ruby-forum.com/u/staypufd)\
**Post date:** [June 27, 2008, 1:21pm UTC](https://www.ruby-forum.com/t/authentication-cookies/196728/5 "2008-06-27T13:21:39Z")

</div>

Frederick C. wrote:

> On 27 Jun 2008, at 12:06, Sam G. wrote:  
> In that case you can’t share a cookie. Have you considered OpenID ?
> 
> Fred

I’m not familiar with that what is it?

---

<div class="post-metadata">

**Author:** ![staypufd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@staypufd](https://www.ruby-forum.com/u/staypufd)\
**Post date:** [June 27, 2008, 2:21pm UTC](https://www.ruby-forum.com/t/authentication-cookies/196728/6 "2008-06-27T14:21:47Z")

</div>

Frederick C. wrote:

> On 27 Jun 2008, at 12:21, Sam G. wrote:
> 
> > Frederick C. wrote:
> > 
> > > On 27 Jun 2008, at 12:06, Sam G. wrote:  
> > > In that case you can’t share a cookie. Have you considered OpenID ?
> > > 
> > > Fred
> > 
> > I’m not familiar with that what is it?
> 
> [http://openid.net/](http://openid.net/)
> 
> There’s a rails plugin for it
> 
> Fred

can’t thank you enough for all your help.

kind regards  
mauro

---

<div class="post-metadata">

**Author:** ![staypufd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@staypufd](https://www.ruby-forum.com/u/staypufd)\
**Post date:** [June 27, 2008, 2:07pm UTC](https://www.ruby-forum.com/t/authentication-cookies/196728/7 "2008-06-27T14:07:59Z")

</div>

On 27 Jun 2008, at 12:21, Sam G. wrote:

> Frederick C. wrote:
> 
> > On 27 Jun 2008, at 12:06, Sam G. wrote:  
> > In that case you can’t share a cookie. Have you considered OpenID ?
> > 
> > Fred
> 
> I’m not familiar with that what is it?

> **[OpenID - OpenID Foundation](https://openid.net/)**
>
> Our mission is to lead the global community in creating identity standards that are secure, interoperable and privacy-preserving.

There’s a rails plugin for it

Fred
