Skip to content

Instantly share code, notes, and snippets.

@kevinelliott
Created March 22, 2012 02:30
Show Gist options
  • Save kevinelliott/2155230 to your computer and use it in GitHub Desktop.
Save kevinelliott/2155230 to your computer and use it in GitHub Desktop.
Override session lookup for ActiveRecord::SessionStore::Session to find by session id in request header X_Session_ID, and fallback to default lookup.
module ActionDispatch
module Session
class AbstractStore
# Override the default way to extract the session id
# First check for a X_Session_ID request header, otherwise fallback to cookies/params
def extract_session_id(env)
request = Rack::Request.new(env)
sid = request.env['HTTP_X_SESSION_ID']
sid ||= request.cookies[@key]
sid ||= request.params[@key] unless @cookie_only
sid
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment