Skip to content

Instantly share code, notes, and snippets.

@davidcomfort
Created December 13, 2015 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcomfort/a5585824f3c41052b6c6 to your computer and use it in GitHub Desktop.
Save davidcomfort/a5585824f3c41052b6c6 to your computer and use it in GitHub Desktop.
import requests
session = requests.Session()
params = {'username': 'username', 'password': 'password'}
s = session.post("http://pythonscraping.com/pages/cookies/welcome.php", params)
print("Cookie is set to:")
print(s.cookies.get_dict())
print("-----------")
print("Going to profile page...")
s = session.get("http://pythonscraping.com/pages/cookies/profile.php")
print(s.text)
Cookie is set to:
{'username': 'username', 'loggedin': '1'}
-----------
Going to profile page...
Hey username! 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