Rich_F
Rich_F

Reputation: 2056

Rack::Session::Pool Sessions in Sinatra

I can't seem to get these sessions to continue into other pages.

app.rb:

    class MyApp < Sinatra::Base
        use Rack::Session::Pool, :expire_after => 60 * 1

        get "/" do
            @foo = "one two three"
            erb :index
        end

        get "/first" do
            session[:foo] = Time.now
            session[:message] = "ALPHA"
            session[:message1] = "CHARLIE"

            erb :first
        end

        get "/second" do
            session[:message2] = "BRAVO2"

            erb :second
        end
    end

Inside /first and /second:

Sess: <%= session.inspect %><br>

The session doesn't want to carry across pages. On /first I'm displaying this:

Sess: {"message"=>"ALPHA", "message1"=>"CHARLIE", "foo"=>2015-12-01 17:05:31 -0500}

On /second I'm displaying this:

Sess: {"message2"=>"BRAVO2"}

Upvotes: 0

Views: 340

Answers (1)

Rich_F
Rich_F

Reputation: 2056

Just needed a restart. Figure that.

Upvotes: 1

Related Questions