Code: Select all
<?php
//include('../includes/data.php');
if(isset($_COOKIE['cart']) & $_COOKIE['cart']!='' & $_GET['add']==''){
prin();
}
if(isset($_GET['add'])){
$add=$_GET['add'];
encode($add);
prin();
}
function prin(){
$cart = preg_split('/&/', $_COOKIE['cart']);
print '<pre>';
print_r ($cart);
print '</pre>';
}
function encode($new){
if(isset($_COOKIE['cart']) & $_COOKIE['cart']!=''){
$cart=$_COOKIE['cart'];
$cart=$cart . '&' . $new;
setcookie("cart", $cart);
}else{
setcookie("cart", $new);
}
}
print '<br><br><br><a href="remove.php">Remove cookie</a>';
?>The problem im having is, when i do index.php?add=1 , it will show
Code: Select all
Array
(
[0] =>
)I just want it to show up the first time.. : p
Thanks..
-NSF