syntax for cookie setcookie(name, value, expire)
Example:
<!DOCTYPE html>
<?php
$cookie_name = "your_user";
$cookie_value = "php guides";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30)); // 86400 = 1 day
?>
<html>
<body>
<?php
if(!isset($_COOKIE[$cookie_name])) {
echo "Cookie named '" . $cookie_name . "' is not set!";
} else {
echo "Cookie '" . $cookie_name . "' is set!<br>";
echo "Your Cookie Value is: " . $_COOKIE[$cookie_name];
}
?>
<p style="color:red">If You Don't See value reload to see cookie value</p>
</body>
</html>
No comments:
Post a Comment