Sinatra not persisting session with redirect on Chrome
Add this to your main app file: use Rack::Session::Cookie, :key => 'rack.session', :path => '/', :secret => 'some-random-string'
With that added, you should be able to assign session['whatever'] and have it work as expected.
By doing enable :sessions
you just get access to session per request.Sinatra has no way to keep the reference to the previous call (your redirect) as it is treated as another request.
Thus, long story short:
set :session_secret, "SecureRandom.new(10) generated thing"enable :sessions
always use enable :sessions
with a secret, otherwise your session is recreated every time rack sees a request.
Please try to disable all custom cookie managament extensions is Chrome if any.After that check headers in Developer tools → Network. Should see 'Cookie:' field.