<html>
<?php
if
(isset(
$_POST
[
"Submit1"
])) {
setcookie(
"name"
,
$_POST
[
"name"
], time() + 3600,
"/"
,
""
, 0);
setcookie(
"age"
,
$_POST
[
"age"
], time() + 3600,
"/"
,
""
, 0);
setcookie(
"city"
,
$_POST
[
"city"
], time() + 3600,
"/"
,
""
, 0);
echo
"<center><h4>Your Cookies are now Created...</h4></center>"
;
}
if
(isset(
$_POST
[
"Submit3"
])) {
setcookie(
"name"
,
""
, time() - 3600,
"/"
,
""
, 0);
setcookie(
"age"
,
""
, time() - 3600,
"/"
,
""
, 0);
setcookie(
"city"
,
""
, time() - 3600,
"/"
,
""
, 0);
echo
"<center><h4>Your Cookies are now Deleted...</h4></center>"
;
}
?>
<head>
<meta charset=
"utf-8"
>
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<link rel=
"stylesheet"
href=
<script src=
</script>
<script src=
</script>
</head>
<body style=
"background:#FADBD8 "
>
<center>
<div
class
=
"container "
>
<h2 style=
"color:green"
>GeeksforGeeks</h2>
<strong>Cookie portal</strong><br/><br/>
<form method=
"POST"
action=
""
>
<div
class
=
"form-group"
>Enter Your Name:
<input
class
=
"form-control"
type=
"text"
name=
"name"
style=
"width:500;"
>
</div>
<div
class
=
"form-group"
>Enter Your Age:
<input
class
=
"form-control"
type=
"text"
name=
"age"
style=
"width:500;"
></div>
<div
class
=
"form-group"
>Enter Your City:
<input
class
=
"form-control"
type=
"text"
name=
"city"
style=
"width:500;"
></div>
<br/>
<input type=
"submit"
name=
"Submit1"
value=
"Create Cookie"
style=
"width:150;margin-left:10px;"
>
<input type=
"submit"
name=
"Submit2"
value=
"Retrieve Cookie"
style=
"width:150;"
>
<input type=
"submit"
name=
"Submit3"
value=
"Delete Cookie"
style=
"width:150;"
>
</form>
</div>
<?php
if
(isset(
$_POST
[
'Submit2'
])) {
if
(isset(
$_COOKIE
[
"name"
])) {
echo
"Name = "
.
$_COOKIE
[
"name"
].
"<br/>"
;
echo
"Age = "
.
$_COOKIE
[
"age"
].
"<br/>"
;
echo
"City = "
.
$_COOKIE
[
"city"
].
"<br/>"
;
}
else
{
echo
"<center><h4>Sorry can't retrieve..
Your Cookies are deleted !!</h4></center>";
}
}
?>
</center>
</body>
</html>