forked from andrewjkerr/security-cheatsheets
-
Notifications
You must be signed in to change notification settings - Fork 255
/
cookies
35 lines (30 loc) · 1.12 KB
/
cookies
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# andrew <andrewjkerr>
# javascript
document.cookie; # can pair with alert();
# edit cookies in chrome
Settings -> Advanced Settings -> Privacy -> Content -> Cookies
or "Edit This Cookie" plugin
# edit cookies in firefox
Preferences -> Privacy -> Show Cookies
or "Cookies Manager+" addon
# cookies with ruby
# Use HTTP::Cookie library <https://github.com/sparklemotion/http-cookie>
# Following examples were taken from the readme.md from above repository
## Several cookies
jar = HTTP::CookieJar.new
jar.load(filename) if File.exist?(filename)
header["Set-Cookie"].each { |value| jar.parse(value, uri) }
header["Cookie"] = HTTP::Cookie.cookie_value(jar.cookies(uri))
## One cookie
cookie = HTTP::Cookie.new("uid", "u12345", domain: 'example.org',
for_domain: true,
path: '/',
max_age: 7 * 86400)
header['Set-Cookie'] = cookie.set_cookie_value
# cookies with python
# python has a cookie library!
# Following example taken from the python documentation
import cookielib, urllib2
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
r = opener.open("http://example.com/")