In my Sinatra app I am using rack sessions
use Rack::Session::Cookie, :secret => ENV['SECRET']
It seems to be setting a cookie for every page load, even if I am not setting anything in a session. Is there a way to change it to only set a cookie if a session is set?
Rack::Session::Cookiekeeps sessions into a marshaled RubyHash.Basically it is marshaling your session and persist it into cookies.
And it does not care your session is an empty
Hash,it will be marshaled and persisted into cookies anyway.
Do you really need to keep your sessions in cookies?
Perhaps
use Rack::Session::Poolto keep your sessions in a memory pool?Then it will set a cookie only once.