1

当我将网站上传到生产服务器时,似乎与我的会话不一致。一切都在我的开发机器上相应地工作,但我的会话在生产服务器上停止工作。我尝试上传到不同的服务器,它运行良好,这意味着代码没有问题。

这些会话在将用户重定向到他们使用标题的先前页面以及存储和输出购物车数组中的项目总数时很有用。

当 php 文件从本地开发移动到生产服务器时,会话或标头常见的不一致是什么,我该如何解决?

这是我的代码示例。

//=========================================================================
//SECTION 1: Add items to cart
//=========================================================================
if((isset($_POST["submit-checkout"])) OR (isset($_POST["submit-continue"]))) {
    //Posted variables
    $freight = $_POST["freight"];
    $order_quantity = $_POST["order_quantity"];
    $price = $_POST["price"];
    $type = $_POST["type"];
    $weight = $_POST["weight"];
    $minimum = $_POST["minimum"];
    $product_name= $_POST["product_name"];
    $id = $_POST["id"];
    $url = "".$_SESSION["return_to_page"]."";
    //Check for order quantity and redirect if it's less than minimum acceptable value
    if($order_quantity < $minimum) {
        $_SESSION["error"] = $product_name;
        redirect_to("$url");
    }       
    //Set url to redirect user based on whether they want to check out or to keep shopping for more products
    if(isset($_POST["submit-checkout"])) {
        $url ="cart.php";
    } else {
        $url = "".$_SESSION["return_to_page"]."";
    }
    addtocart($url, $order_quantity, $type, $weight, $product_name, $id, $price, $freight);
}
4

0 回答 0