Cross domain cookies


#1

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


#2

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


#3

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


#4

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


#5

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