When I ran this is firefox as
Code:
<html>
<head>
<title></title>
<meta content="">
<style></style>
</head>
<body>
<?php
if(isset($_COOKIE['cart_id'])) {
$cart_id = $_COOKIE['cart_id'];
} else {
$cart_id = md5(uniqid(rand()));
setcookie("cart_id", $cart_id, time() + 3600);
}
echo ($_COOKIE['cart_id']); ?>
</body>
</html>
I got an error form firefox saying the headers had already been set and thus the cookie couldn't be added. But after changing it to
Code:
<?php
if(isset($_COOKIE['cart_id'])) {
$cart_id = $_COOKIE['cart_id'];
} else {
$cart_id = md5(uniqid(rand()));
setcookie("cart_id", $cart_id, time() + 3600);
}
<html>
<head>
<title></title>
<meta content="">
<style></style>
</head>
<body>
<?PHP
echo ($_COOKIE['cart_id']); ?>
</body>
</html>
It worked fine.