#388 √ resolved
pchm

problem with domains in cookie sessions

Reported by pchm | June 29th, 2008 @ 12:29 PM | in 0.9.4

I think there's a bug in cookie sessions – specifically with cookie domains. After digging through the code I figured out that in order to set a domain for sessions I need to do something like this:

# Session config:
Merb::Config.use do |c|
  c[:session_id_key] = '_sess'

  c[:session_secret_key]         = 'd49318052654c1e36a6b8d353f597db402474135'
  c[:session_store]                 = 'cookie'
  c[:session_cookie_domain]  = '.mydomain.com'
end

Unfortunately, it doesn't seem to work. Domain name isn't being set in cookie headers and, as a result, merb loses sessions between subdomains.

In a case, when I manually set a cookie with a domain name provided, it works as intended:

cookies[:test] = {:value = 'test', :expires => Time.now, :domain => '.mydomain.com'}

Also, it would be nice to be able to specify domain names for cookies globally in a config file or init.rb.

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins