我有以下問題,我試圖設置cookie沒有任何成功。所以它看起來像它設置的cookie然而,當我試圖訪問相同或以下頁面,我得到錯誤的setcookie();
函數返回true「未定義指數....」setcookie();沒有設置Cookie
<?
session_start();
ob_start();
echo setcookie("order",$_SESSION['cart'],time()+3600,'/',NULL);
//added to see if Cookie is set
echo "<br/>";
var_dump($_COOKIE);
exit();
if($_GET['paypal'] == 1){
header("Location: /paypal-express-checkout/process.php");
}else{
header("Location: /insert_order.php");
}
ob_end_flush();
exit();
?>
下一頁如下這樣
<?php
session_start();
include_once("../includes/inc_config.php");
include_once("../order.php");
include_once("config.php");
include_once("paypal.class.php");
#region POST
if(!isset($_GET['token'])) //Post Data received from product list page.
{
//Mainly we need 4 variables from an item, Item Name, Item Price, Item Number and Item Quantity.
if(!isset($_COOKIE['order'])){
exit();
}
$paypal_data = '';
$ItemTotalPrice = 0;
$order = unserialize($_COOKIE['order']);
print_r($order);
exit;
在下一頁加載時,Cookie只在「'_COOKIE''」可見「。 – MrTux 2014-09-12 21:31:13
**常見陷阱:**在下一次加載該cookie應該可見的頁面之前,Cookie不會變得可見。要測試cookie是否成功設置,請在cookie過期之前檢查下一個加載頁面上的cookie。 – Class 2014-09-12 21:32:05
根據我原來的帖子,cookie在下一頁(下一個加載的頁面)不可見 – zbora23 2014-09-12 21:40:33