Skip to content

Instantly share code, notes, and snippets.

@davidcomfort
Created December 13, 2015 22:24
Show Gist options
  • Save davidcomfort/975d9959dfdd8a9a03f9 to your computer and use it in GitHub Desktop.
Save davidcomfort/975d9959dfdd8a9a03f9 to your computer and use it in GitHub Desktop.
import requests
params = {'username': 'Ryan', 'password': 'password'}
r = requests.post("http://pythonscraping.com/pages/cookies/welcome.php", params)
print("Cookie is set to:")
print(r.cookies.get_dict())
print("-----------")
print("Going to profile page...")
r = requests.get("http://pythonscraping.com/pages/cookies/profile.php", cookies=r.cookies)
print(r.text)
Cookie is set to:
{'username': 'Ryan', 'loggedin': '1'}
-----------
Going to profile page...
Hey Ryan! Looks like you're still logged into the site!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment