title: Getting shopping cart items using post request python
body: <p>I have been browsing stackoverflow for the past couple of days and have been looking at a lot of different videos and forums, but I can't get this to work for some reason. I'm trying to automatically add an item to cart on <a href="https://www.toytokyo.com/medicom-toy-kaws-together-black/" rel="nofollow noreferrer">https://www.toytokyo.com/medicom-toy-kaws-together-black/</a> and I even get the correct 200 response code, but when check the shopping cart it says that its empty.</p>
  
  <p>Here is the Request Payload that it needs.</p>
  
  <pre><code>------WebKitFormBoundary2abcTSnRV9XhBx4h
  Content-Disposition: form-data; name="action"
  
  add
  ------WebKitFormBoundary2abcTSnRV9XhBx4h
  Content-Disposition: form-data; name="product_id"
  
  4806
  ------WebKitFormBoundary2abcTSnRV9XhBx4h
  Content-Disposition: form-data; name="qty[]"
  
  1
  ------WebKitFormBoundary2abcTSnRV9XhBx4h--
  </code></pre>
  
  <p>and here is what I'm doing to send the POST request.</p>
  
  <pre><code>payload = {'action': 'add', 'product_id': 4806, 'qty[]': 1}
  
  get = requests.get("https://www.toytokyo.com/medicom-toy-kaws-together-black/")
  
  post = requests.post("https://www.toytokyo.com/remote/v1/cart/add", data=payload)
  
  print(post.status_code, post.content)
  
  get = requests.get("https://www.toytokyo.com/cart.php")
  
  print(get.status_code, get.text)
  </code></pre>
  
  <p>I'm not sure if I'm doing something wrong, but I get the correct response from what I can tell.</p>
  
  <p>EDIT: ANSWER BELOW</p>
  
  <p>Just for anyone that might stumble across this later on, I took the advice of the people who commented below and created a variable called <code>session</code> and assigned it using <code>session = requests.Session()</code> which allows your program to persist across every new request that you send. the <code>session</code> variable also has all of the same methods as the request itself. So I just replaced everything that used requests and replaced it with session. </p>