0

Section Of My Code:

<?php
if( isset($_POST["paymentmethod"]) && $_POST["paymentmethod"] == "creditcards" ){

$id_cname = $_SESSION["id_cname"];

$post = array(
"$id_cname"=>$_SESSION["character"],
'quantity'=>$_SESSION["q"],
'product_id'=>$_SESSION["id_product"]);

$ch = curl_init('http://localhost/products/index.php?route=checkout/cart/add');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
header('Content-Type: text/html');
echo curl_exec($ch);





die();
}else{

}
?>

I am very new to CURL and do not understand it fully, I performed a POST request to a CMS that I am using as I want to add an item to a cart for a user automatically when they select their payment method.

I then get a success message saying that the item has been added to the cart, but when I check my cart the item is not their.

How do I save the cookies for the user to use with CURL?

I really hope you can help me!

p.s. Sorry for my bad English, it's not my first language, I hope you understand me!

EDIT:

So basically what I am looking to do is save a cookie that was gotten from my POST request so the user will then have the item in their cart!

Thanks!

rakupu
  • 109
  • 1
  • 8
  • `CURLOPT_HTTPHEADER` to inject the `Cookie` (probably from/to `"PHPSESSID"`). -- The real question is: why would you want to forward the cart adding request like this? Doesn't seem kosher nor reliable. – mario Nov 19 '17 at 03:05
  • How would I implement this in to my code? I am very new to CURL, would you be willing to show me how I would implement it (And I am building a website alongside the CMS and it's their for a user to press it when on the main website) – rakupu Nov 19 '17 at 03:08
  • How exactly would I give the user the cookie, could you show me? (Like I say, I am super new to CURL) – rakupu Nov 19 '17 at 03:08

0 Answers0