Search code examples
rubysessionrack

session not pesisting between requests in Rack::Session::Cookie


trying to implement a session cookie based using rack, the application seems not be persisting the information between requests, after the user succesfully log in it was supposed to save a flash message to be used at index when redirected, what isn't happening:

-PostHandler

  env['rack.session'][:flash] = "Successfully Logged In."
  res.status = 302
  res['Location'] = '/login'

-Routes

  res = Rack::Response.new(render("index", @flash="#{env['rack.session'][:flash] || "No flash."}"))

The stack is implemented this way with the Rack::Session::Cookie at the begin of it:

  use Routes
  use PostHandler
  run Application.new

wdId?


Solution

  • for discussion sake, the problem was related with the way cache was implemented, it was 1 layer below session at the app stack and was setting the ignore_headers: ['Set-Cookie'], what makes the application doesn't set cookie for the users, it can be reversed setting at cache config, ignore_headers: [];