$cookie_name = "my cookie";
$cookie_value = "my value";
$cookie_new_value = "my new value";
// Create a cookie,
setcookie($cookie_name, $cookie_value , time() + (86400 * 30), "/"); //86400 = 24 hours in seconds
// Get value in a cookie,
$cookie_value = $_COOKIE[$cookie_name];
// Update a cookie,
setcookie($cookie_name, $cookie_new_value , time() + (86400 * 30), "/");
// Delete a cookie,
setcookie($cookie_name, '' , time() - 3600, "/"); // time() - 3600 means, set the cookie expiration date to the past hour.
if ($_GET['action'] == 'exit'){
// delete cookies with js and then in server with php:
echo '
<script type="text/javascript">
var delete_cookie = function(name) {
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT;";
};
delete_cookie("madw");
delete_cookie("usdw");
</script>
';
unset($_COOKIE['cookie_name']);
unset($_COOKIE['cookie_time']);