Skip to content

Instantly share code, notes, and snippets.

@fidothe
Created May 4, 2011 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fidothe/955256 to your computer and use it in GitHub Desktop.
Save fidothe/955256 to your computer and use it in GitHub Desktop.
Rack middleware to prevent cookies coming in or out except on POST
class Cookieblind
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
unless request.post?
env.delete("HTTP_COOKIE")
end
status, headers, body = @app.call(env)
response = Rack::Response.new(body, status, headers)
unless request.post?
response.header['Set-Cookie'] = "";
end
response.finish
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment