title: Performing Login with Python requests (Cookies not activated)
body: <p>I'm trying to perform a login with the python requests module. I first post to the login-page with my user name and password to save the cookie from the response. After that I try to enter the password protected page. The problem is that the response page says I have to activate cookies to login to this page, but I get a Cookie back that I can display.
  Here is the code</p>
  
  <p>Input parameters from the login page:</p>
  
  <pre><code>&lt;input type="hidden" name="security_token" value="kAvcFvod9KSrGLS1JX30+dhNI8QhmVpbqbe00zuvztE="&gt; 
  &lt;input type="hidden" name="login_ticket" value="3781fe1e16e441e9957bec8b32aa4630"&gt;
  &lt;input type="hidden" name="resolution"  value=""&gt;
  &lt;input type="hidden" name="device_pixel_ratio" value="1"&gt;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>&lt;input type="text" autofocus id="loginname" name="loginname" value="" size="20" maxlength="63"&gt;
  &lt;input type="password"  id="password" name="password" size="20"&gt;
  </code></pre>
  
  <p>Python Code:</p>
  
  <pre><code>import requests
  
  login = r'LOGIN_URL'
  url = 'PROTECTED_URL'
  
  values = {'loginname': 'USERNAME', 'password': r'PASSWORD','security_token' : r'kAvcFvod9KSrGLS1JX30+dhNI8QhmVpbqbe00zuvztE=', 'login_ticket' : r'3781fe1e16e441e9957bec8b32aa4630', 'resolution' : '', 'device_pixel_ratio' : '1'}
  
  session = requests.Session()
  
  r = session.post(login, data = values)
  print r.content
  print r.cookies
  s = session.get(url)
  </code></pre>
  
  <p>(I get the security token and login ticket from another get request before) 
  So, the r.content prints out a web page which basically says: Login not successful, because Cookies are not activated.</p>
  
  <p>But the output from the r.cookies is:</p>
  
  <pre><code>&lt;RequestsCookieJar[&lt;Cookie Seminar_Session=abbfdd4e96ee048b1b97fd027a2c7de4 for URL/&gt;]&gt;
  </code></pre>
  
  <p>And s.get just returns the login page you get if you are not logged in and try to access the protected page.</p>
  
  <p>So I think everything works just fine, just the web page thinks I don't save the sent cookies. How can I work around that?</p>
  
  <p>EDIT (Solution):</p>
  
  <p>Worked, thanks!</p>
  
  <p>Solution with BeautifulSoup:</p>
  
  <pre><code>import requests
  from bs4 import BeautifulSoup
  
  login = 'LOGIN_URL'
  url = 'PROTECTED_URL'
  
  session = requests.Session()
  
  l = session.get(login) 
  
  soup = BeautifulSoup(l.content,'lxml')
  
  values = {'loginname': 'USERNAME', 'password': r'PASSWORD','security_token' : soup.find('input')['value'], 'login_ticket' : soup.find('input').next_sibling.next_sibling['value'], 'resolution' : '', 'device_pixel_ratio' : '1'}
  
  r = session.post(login, data = values)
  s = session.get(url)
  </code></pre>