Skip to content

Instantly share code, notes, and snippets.

@feifanzhou
Created August 1, 2014 17:19
Show Gist options
  • Save feifanzhou/178089347821cdf5ba9f to your computer and use it in GitHub Desktop.
Save feifanzhou/178089347821cdf5ba9f to your computer and use it in GitHub Desktop.
Rails — Parse cookies from request header
module HeaderCookies
def header_cookies(req=nil)
req ||= request
cookie_dough = request.headers['Cookie'].split '; '
Hash[cookie_dough.map do |c|
pieces = c.split '='
[pieces[0].to_sym, pieces[1]]
end]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment