Created
June 3, 2015 17:56
-
-
Save godfat/25f79486d35f28cf12e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MigrateCookie < Struct.new(:app) | |
def call env | |
cookies = Rack::Utils.parse_query(env['HTTP_COOKIE'], ';,') | |
case cookies['_session_id'] | |
when Array | |
status, headers, body = app.call(env) | |
headers['Set-Cookie'] = | |
"#{headers['Set-Cookie']}\n#{expire_old_session}" | |
[status, headers, body] | |
else | |
app.call(env) | |
end | |
end | |
private | |
def expire_old_session | |
"_session_id=deleted; path=/;" \ | |
" expires=Thu, Jan 01 1970 00:00:00 UTC; HttpOnly" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment