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!