In above syntax, there are multiple parameters, so let explain one by one
1- Name:-This is a required parameter and it specifies the name of cookie 2- value:-This specifies the value of cookies and it is an optional parameter 3- expire:-This is an optional parameter and specifies the time of cookie expire. 4- path:- It the server path of the cookie.(Optional) 5- domain:- It specifies the domain name of the cookie.(Optional) 6- secure:- It specifies cookie should only be transmitted over a secure HTTPS connection.
(optional) 7- HTTP only:-This is optional and by default it is FALSE. If we set to TRUE the cookie will be accessible only through the HTTP protocol\
If we want to modify in a cookie then,we should use the same function setcookie() with different argument values. If we want to delete the cookie after a fixed time then, we can set an expiration time in that function.
you can see below example for better understanding
$cookie_name = "user";//set the cookie same
$cookie_value = "Manish";//set the cookie value
setcookie($cookie_name, $cookie_value, time() + (36400 * 30), "/");//use setcookie()
echo "Cookie named '" . $cookie_name . "' is not set!";
echo "Cookie '" . $cookie_name . "' is set!<br>";
echo "Value is: " . $_COOKIE[$cookie_name];
I hope this blog will help you to set a cookie in your web application.