asked on
$cart = $_COOKIE["cart"];
$aOrder = array(
"strName"=>$strName,
"strColor"=>$strColor,
"nQty"=>$nQty);
$cart[] = $aOrder;
setcookie("cart",$cart,time()+3600,"/");
ASKER
$_COOKIE["testData"] = "Hello World!";
var_dump($_COOKIE);
ASKER
ASKER
<form method="post" action="test.php">
Name: <input type="text" id="" name="strName"/><Br/>
Color: <input type="text" id="" name="strColor"/><Br/>
Qty <input type="text" id="" name="nQty"/><Br/>
<input type="submit" />
</form>
<?
#get the cart contents
$cart = $_COOKIE["cart"];
#pretend that i'm adding a product...
$aOrder = array(
"strName"=>"$strName",
"strColor"=>"$strColor",
"nQty"=>"$nQty");
$cart[] = $aOrder;
# here i'm setting my cart to the cookie...
setcookie("cart",$cart,time()+3600,"/");
# returns same array as above even after refresh???????
print_r($cart);
?>
<a href="additem.html">Add/Append Another Item To Cart</a>
<form method="post" action="test.php">
Name: <input type="text" id="" name="strName"/><Br/>
Color: <input type="text" id="" name="strColor"/><Br/>
Qty <input type="text" id="" name="nQty"/><Br/>
<input type="submit" />
</form>
<?php
// MAKE SURE WE SEE ERRORS
error_reporting(E_ALL);
#get the cart contents
$cart = $_COOKIE["cart"];
#pretend that i'm adding a product...
$aOrder = array(
"strName"=>"$strName",
"strColor"=>"$strColor",
"nQty"=>"$nQty");
$cart[] = $aOrder;
# here i'm setting my cart to the cookie...
// TEST TO SEE IF THE setcookie() FUNCTION WORKED
if (!setcookie("cart",$cart,time()+3600,"/"))
{
echo "<br/>SETCOOKIE FAILED \n";
}
# returns same array as above even after refresh???????
print_r($cart);
?>
<a href="additem.html">Add/Append Another Item To Cart</a>
ASKER
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
Best, ~Ray