unset domain for localhost by default and support options when setting cookie #118

wants to merge 2 commits into


None yet
4 participants

should fix #113 & #115

First, by default unset domain when @request.host == 'localhost'. Setting domain to localhost does not work in particular on Chrome.

I also added the possibility to pass cookie options when setting a cookie.

Added corresponding tests and doc.

just like @rykann in #91 I just realized there is some history (#66) for per cookie options. I too definitely prefer the way I suggested since it is the way response.set_cookie works.

+ cookie_route do
+ cookies['foo'] = {:value => 'bar'}
+ response['Set-Cookie'].lines.detect { |l| l.start_with? 'foo=bar' }
+ end

rykann Mar 3, 2014

Looks like an assertion is needed here.


colinsurprenant Mar 6, 2014

true this! will do.

rykann commented Mar 3, 2014

These changes look good to me, with an assertion added to the spec I commented on. Thanks for adding the ability to set cookie options. This takes care of #91 as well.

a friendly ping!

I second this ping 👍

Ran into this issue today!


zzak commented May 22, 2015


I'm sorry for the late response!

I will work on a patch to unset the domain for localhost, but will not be able to merge the following spec changes: 'sets a cookie options using hash' as this could lead to other unexpected behavior.

zzak added a commit that referenced this pull request May 22, 2015

@zzak zzak closed this May 22, 2015

zzak added a commit to zzak/sinatra-contrib that referenced this pull request Jul 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment