<?php

$request_body = file_get_contents('php://input');
$data = json_decode($request_body, true);

$shipping = $data["shipping"];
setcookie('shipping', $shipping, time() + 86400, "/"); // 86400 = 1 day
if($shipping == 'Standard Shipping') {
    setcookie('shipping_price', 3, time() + 86400, "/"); // 86400 = 1 day
}
if($shipping == 'Fast Shipping') {
    setcookie('shipping_price', 7, time() + 86400, "/"); // 86400 = 1 day
}

$email = $data["email"];
setcookie('email', $email, time() + 86400, "/"); // 86400 = 1 day
$password = $data["password"];

if($email && $password) {

    $data = [
        'shipping' => $shipping,
        'email' => $email,
        'password' => $password,
    ];

    require './save_data.php';
    $response = saveData($data);

    header('Content-Type: application/json; charset=utf-8');
    echo $response;

}