Skip to content

Instantly share code, notes, and snippets.

@snoble
Created September 10, 2012 15:21
Show Gist options
  • Save snoble/3691480 to your computer and use it in GitHub Desktop.
Save snoble/3691480 to your computer and use it in GitHub Desktop.
Experiment for understanding how different browsers deal with 3rd party cookies
# set foo and foofoo to localhost in your hosts file.
# ruby simple.rb
# load http://foofoo:4567/cookie to make sure their is no initial cookie (go to http://foofoo:4567/clear_cookie if there is)
# load http://foo:4567/test
# load http://foofoo:4567/cookie to see resulting cookies
# load http://foofoo:4567/test
# load http://foofoo:4567/cookie to see resulting cookies
require 'sinatra'
get '/cookie' do
"ccc: #{request.cookies["ccc"]}"
end
get '/clear_cookie' do
response.delete_cookie('ccc')
"deleted ccc"
end
get '/track.gif' do
response.set_cookie('ccc', 'I got set')
content_type 'image/gif'
"GIF89a\001\000\001\000\200\000\000\000\000\000\000\000\000!\371\004\001\000\000\000\000,\000\000\000\000\001\000\001\000\000\002\002D\001\000;"
end
get '/test' do
'<html><head></head><img src="http://foofoo:4567/track.gif"></img><body>blah</body></html>'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment