title: Getting session id through redirect in Python
body: <p>First of all, my programming background is mostly limited to server side scripting and this is pretty much the first time I'm trying to parse a website so please forgive me if my question is ridiculous.</p>
  
  <p>I am trying to pull some data from a website (battlefield.com) which requires authentication through another site.</p>
  
  <p>I have a following script:</p>
  
  <pre><code>import requests
  
  url_login = "https://signin.ea.com/p/web/login?execution=e1567523006s1&amp;initref=https%3A%2F%2Faccounts.ea.com%3A443%2Fconnect%2Fauth%3Fredirect_uri%3Dhttps%253A%252F%252Fwww.battlefield.com%252Flogin_check%26state%3D5223dcd1-5f9c-47a1-940c-1d6b306454f9%26response_type%3Dcode%26client_id%3DBattlefield-CoreWeb"
  
  url_bf = "https://www.battlefield.com/companion/career/mypersonalid/bf1"
  
  s = requests.Session()
  
  payload = {
      "username": "myemail",
      "password": "mypassword"
  }
  
  req1 = s.post(url_login, data=payload)
  
  req2 = s.get(url_bf)
  
  print (s.cookies)
  </code></pre>
  
  <p>When I do this process manually, I go to battlefield.com, click sign in and then the page redirects me to the <code>url_login</code> page.
  Then I post the payload and the page redirects me back to the battlefield page.</p>
  
  <p>What I am trying to do is to get the sessionID from the battlefield page after logging in successfully.</p>
  
  <p>The output of the script above is (modified the sessionid and removed tags):</p>
  
  <pre><code>RequestsCookieJar[Cookie ealocale=en-us for .battlefield.com/, Cookie JSESSIONID=1DF14B ... 3DAF.eanshprdaccounts38 for signin.ea.com/p/]
  </code></pre>
  
  <p>But I don't think this sessionID is correct. When I manually check the <code>sessionID</code> using Chrome Inspector from the battlefield.com page after logging in, the name of the session appears to be different and it has a completely different value:</p>
  
  <p><a href="https://i.stack.imgur.com/fsgpe.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/fsgpe.jpg" alt="Screenshot"></a></p>
  
  <p>So my question is, how can I get the <code>BTLF_SESSID</code>?</p>
  
  <p>Thank you in advance</p>