views:

192

answers:

1

Hi guys,

Am having trouble getting enable :sessions to persist for a simple Sinatra app hosted on passenger/apache. I'm storing the state of session[:authorized] in a cookie. It works locally when hosted on Rack::Handler::Mongrel but I can't seem to get same behaviour on passenger.

I've tried two methods for enabling sessions, both of which don't work on the passenger/apache installation enable :sessions

and

use Rack::Session::Pool, :domain => 'example.com', :expire_after => 60 * 60 * 24 * 365

Any ideas on how to fix?

A: 

We were facing something similar although we were not using Apache / Passenger (in development mode). We resolved it like this -

Comment out the Rack::Session commands from within your Sinatra app. Do it in the config.ru file. and haven only enable :sessions in your sinatra app.

That should work.

globetrotter