How to use Python Requests to login to website, store cookie, then access another page on the website?
<p>I'm trying to login into website using a Python script, store the cookie I receive, and then use that same cookie to access member-only parts of the website. I've read several posts and answers about this topic, but none of the answers have worked for me. </p>

<p>Here is the HTML code for the website login page I'm trying to access.</p>

<pre><code>&lt;form action="/login?task=user.login" method="post"&gt;
    &lt;fieldset&gt;
        &lt;table border="0" cellspacing="0" cellpadding="0"&gt;
        &lt;tbody&gt;
                                                        &lt;tr&gt;
            &lt;td width="70" nowrap=""&gt;Username&amp;nbsp;&amp;nbsp;&lt;/td&gt;
            &lt;td width="260"&gt;&lt;input type="text" name="username" id="username" value="" class="validate-username" size="25"/&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                                                                                &lt;tr&gt;
            &lt;td width="70" nowrap=""&gt;Password&amp;nbsp;&amp;nbsp;&lt;/td&gt;
             &lt;td width="260"&gt;&lt;input type="password" name="password" id="password" value="" class="validate-password" size="25"/&gt;&lt;/td&gt;
         &lt;/tr&gt;
                                                        &lt;tr&gt;
             &lt;td colspan="2"&gt;&lt;label style="float: left;width: 70%;" for="modlgn_remember"&gt;Remember Me&lt;/label&gt;
             &lt;input style="float: right;width: 20%;"id="modlgn_remember" type="checkbox" name="remember" class="inputbox" value="yes"/&gt;&lt;/td&gt;
         &lt;/tr&gt;
         &lt;tr&gt;
            &lt;td  colspan="2" width="100%"&gt; &lt;a href="/reset-password"&gt; Forgot your password?&lt;/a&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td  colspan="2" width="100%"&gt; &lt;a href="/username-reminder"&gt;Forgot your username?&lt;/a&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td colspan="2"&gt;&lt;button type="submit" class="button cta"&gt;Log in&lt;/button&gt;&lt;/td&gt;
&lt;!--                            &lt;td colspan="1"&gt;&lt;a href="/--&gt;&lt;!--"&gt;Register Now&lt;/a&gt;&lt;/td&gt;--&gt;
        &lt;/tr&gt;
        &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;input type="hidden" name="return"
               value="aHR0cHM6Ly9maWYuY29tLw=="/&gt;
        &lt;input type="hidden" name="3295f23066f7c6ab53c290c6c022cc4b" value="1" /&gt;                    &lt;/fieldset&gt;
&lt;/form&gt;
</code></pre>

<p>Here is my own code that I'm using to attempt a login. </p>

<pre><code>from requests import session

payload = {
     'username': 'MY_USERNAME',
     'password': 'MY_PASSWORD'
}

s = session()
s.post('https://fif.com/login?task=user.login', data=payload)

response = s.get('https://fif.com/tools/capacity')
</code></pre>

<p>From everything I have read, this should work, but it doesn't. I've been struggling with this for two days, so if you know the answer, I would love the solution. </p>

<p>For reference, here are all the other StackOverflow posts I have looked at in hopes for an answer:</p>

<ol>
<li><a href="https://stackoverflow.com/questions/12737740/python-requests-and-persistent-sessions">Python Requests and Persistent Sessions</a></li>
<li><a href="https://stackoverflow.com/questions/30605582/logging-in-to-a-site-using-python-requests?lq=1">Logging into a site using Python Reqeusts</a></li>
<li><a href="https://stackoverflow.com/questions/8316818/login-to-website-using-python">Login to website using python</a></li>
<li><a href="https://stackoverflow.com/questions/11892729/how-to-log-in-to-a-website-using-pythons-requests-module/17633072#17633072">How to “log in” to a website using Python's Requests module?</a></li>
<li><a href="https://stackoverflow.com/questions/24260149/python-requests-session-login-cookies">Python: Requests Session Login Cookies</a></li>
<li><a href="https://stackoverflow.com/questions/189555/how-to-use-python-to-login-to-a-webpage-and-retrieve-cookies-for-later-usage">How to use Python to login to a webpage and retrieve cookies for later usage?</a></li>
<li><a href="https://stackoverflow.com/questions/6987876/curl-login-then-curl-download">cUrl Login then cUrl Download</a></li>
</ol>