Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5994713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:51:26+00:00 2026-05-22T23:51:26+00:00

The session is not preserved between requests, though I can’t see what I’m doing

  • 0

The session is not preserved between requests, though I can’t see what I’m doing wrong. Code!

require 'sinatra'
require 'rack/fiber_pool'

class SessionTest < Sinatra::Base
  use Rack::FiberPool
  enable :sessions
  set :session_secret, "foobar"

  get '/' do
        body { session.inspect } #This is always '{}'!
  end

  get '/a' do
    session['user'] = "bob"
    redirect '/'
  end
end

run SessionTest.new
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:51:27+00:00Added an answer on May 22, 2026 at 11:51 pm

    Try this instead:

    require 'sinatra'
    require 'rack/fiber_pool'
    
    class SessionTest < Sinatra::Base
      enable :sessions
      set :session_secret, "foobar"
    
      get '/' do
            body { session.inspect } #This is always '{}'!
      end
    
      get '/a' do
        session['user'] = "bob"
        redirect '/'
      end
    end
    
    use Rack::FiberPool
    run SessionTest.new
    

    Otherwise Sinatra will set up the fiber pool after the session middleware, which doesn’t work. This is not a bug but caused by the way Rack::FiberPool works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Session variables are apparently not working for me. I don't know what I'm doing
Okay so I'm not using any session variables, rather my code looks like this:
How do I flush certain parts of a session but not other parts? For
I've got a load-balanced (not using Session state) ASP.Net 2.0 app on IIS5 running
I am wondering conceptually how load-balancing works on the EJB-level (not web session replication)
i read that upon session.flush() The data will be synchronized (but not committed) when
Is seems that Session Replication in ColdFusion servers less that 9 was considered not
By default the session expiry seems to be 20 minutes. Update: I do not
If I do not specify the following in my web.xml file: <session-config> <session-timeout>10</session-timeout> </session-config>
I have an API that is dependent on certain state information between requests. As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.