Forum: Ruby on Rails cross domain cookies

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Adam D. (Guest)
on 2006-03-09 16:00
(Received via mailing list)
Does anybody know how to access the domain of a cookie from inside
rails?

I am try to integrate phpbb forums into my site and one of the things
phpbb
does is store a cookie.  The forums are at forums.domain.com and the
site is
www.domain.com so i needed to set the cookie domain in phpbb to just be
".domain.com" so both sites can access it.  The trouble is when using
cookies[] in rails, it defaults to www.domain.com.  How do I tell
cookies[]
that i want domain ".domain.com" instead ?

thanks
adam
Jeff J. (Guest)
on 2006-03-09 16:45
Adam D. wrote:
> Does anybody know how to access the domain of a cookie from inside
> rails?
>
> I am try to integrate phpbb forums into my site and one of the things
> phpbb
> does is store a cookie.  The forums are at forums.domain.com and the
> site is
> www.domain.com so i needed to set the cookie domain in phpbb to just be
> ".domain.com" so both sites can access it.  The trouble is when using
> cookies[] in rails, it defaults to www.domain.com.  How do I tell
> cookies[]
> that i want domain ".domain.com" instead ?
>
> thanks
> adam

This page on the WIKI may help.

http://wiki.rubyonrails.com/rails/pages/PhpBB+Integration
Adam D. (Guest)
on 2006-03-09 16:58
(Received via mailing list)
yes thats what i was reading.  but it doesnt discuss the situation where
the
forums are under one subdomain, and the rails site is on another.  I
think
in this config the forums are installed in /public which keeps
everything
under one domain which is not how i have it setup.  I have a page with
an
IFRAME to the forums in another docroot (forums.domain.com).  That is
why i
have the subdomain cookie issue.

adam
Adam D. (Guest)
on 2006-03-09 17:05
(Received via mailing list)
for the sake of saving someone else the trouble here is what i had to
do:

cookies[:mycookiename] = { :value => nil, :expires => Time.now, :domain
=>
".domain.com" }

hope it helps someone else.  My hunch is there is a way to set a default
domain in environment.rb but i havent figured that out yet.


adam
Pazu (Guest)
on 2006-03-09 23:52
(Received via mailing list)
Adam D. <straightflush@...> writes:

> for the sake of saving someone else the trouble here is what i had to
> do:cookies[:mycookiename] = { :value => nil, :expires => Time.now, :domain =>
> ".domain.com" }hope it helps someone else.  My hunch is there is a way to
> set a default domain in environment.rb but i havent figured that out yet

>From "Agile Web D. With Rails", under "Available session options":

:session_domain: The domain of the cookie used to store the session id
on the
browser. Defaults to the application's host name:

ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_domain] =
'.domain.com'

AWDR is a *must* have for anyone working with Rails. I bought the PDF
version
directly from pragprog and it was worth every cent.

http://www.pragmaticprogrammer.com/titles/rails/

-- Pazu <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.