Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Validate a cookie set by the Javascript SDK
- FB_APP_ID = 'your_app_id'
- FB_APP_SECRET = 'your_app_secret'
- facebook_session = CGI.parse(cookies["fbs_#{FB_APP_ID}"].gsub('"', ''))
- sig = facebook_session.delete('sig')
- hash = Digest::MD5.hexdigest((facebook_session.sort.inject("") { |payload, cookie| payload + "#{cookie[0]}=#{cookie[1]}" }) + FB_APP_SECRET)
- # sig == hash => You've got a valid Facebook session cookie
Add Comment
Please, Sign In to add comment