Sinatra - response.set_cookie doesn't work Sinatra - response.set_cookie doesn't work ruby ruby

Sinatra - response.set_cookie doesn't work


The documentation on http://sinatra-book.gittr.com/#cookies says to use the set_cookie helper, but in newer versions of Sinatra (at least from 1.2.0+ and possibly earlier), you should use response.set_cookie to set cookies.

response.set_cookie("my_cookie", :value => "value_of_cookie",                    :domain => myDomain,                    :path => myPath,                    :expires => Date.new(2020,1,1))cookie = request.cookies["my_cookie"]

SUMMARY

don't set localhost as a domain for your cookies because you need to set it to "" or FALSE