Skip to content

Instantly share code, notes, and snippets.

@micahwedemeyer
Created April 6, 2010 18:13
Show Gist options
  • Save micahwedemeyer/357900 to your computer and use it in GitHub Desktop.
Save micahwedemeyer/357900 to your computer and use it in GitHub Desktop.
require 'rack/utils'
class FlashSessionCookieMiddleware
def initialize(app, session_key = 'my_session_key')
@app = app
@session_key = (session_key || 'my_session_key')
end
def call(env)
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
unless params[@session_key].nil?
env['HTTP_COOKIE'] = "#{@session_key}=#{params[@session_key]}".freeze
# puts "env['HTTP_COOKIE'] #{env['HTTP_COOKIE'].inspect}"
end
end
@app.call(env)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment