Guest User

Untitled

a guest
May 24th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. # Validate a cookie set by the Javascript SDK
  2.  
  3. FB_APP_ID = 'your_app_id'
  4. FB_APP_SECRET = 'your_app_secret'
  5.  
  6. facebook_session = CGI.parse(cookies["fbs_#{FB_APP_ID}"].gsub('"', ''))
  7. sig = facebook_session.delete('sig')
  8. hash = Digest::MD5.hexdigest((facebook_session.sort.inject("") { |payload, cookie| payload + "#{cookie[0]}=#{cookie[1]}" }) + FB_APP_SECRET)
  9.  
  10. # sig == hash => You've got a valid Facebook session cookie
Add Comment
Please, Sign In to add comment