Rack Cookie Monster
A rack middleware library that allows for cookies to be passed through form parameters. Specifically, it merges the specified form parameters into the Cookie header of an http request. It gets around the problem of having a flash application which interacts with a web application that uses cookie based sessions.
Contributing
The environment can be configured by using bundler.
gem bundle or rake setup:contrib
Usage
Rails Example:
# In rails initializer
Rack::CookieMonster.configure do |c|
c.eat :_session_id
c.eat :user_credentials
c.share_with /^(Adobe|Shockwave) Flash/
c.share_with "Burt"
end
Rack::CookieMonster.configure_for_rails
Rack Example:
class CookieMonsterApplication
def call(env)
= ::Rack::Request.new(env).
res = ::Rack::Response.new
res.write %{
<html>
<head>
<title>Form</title>
</head>
<body>
<form action="/" method="post">
Cookie 1: <input type="text" name="cookie_1" />
Cookie 2: <input type="text" name="cookie_2" />
Non Cookie: <input type="text" name="non_cookie" />
<input type="submit" />
</form>
</body>
#{
.map do |k,v|
"<p>#{k} - #{v}</p>"
end.join("\n")
}
</html>
}
res.finish
end
end
use Rack::CookieMonster, {
:cookies => [:cookie_1, :cookie_2],
:share_with => /firefox/i
}
run CookieMonsterApplication.new