is a cookie?
A Cookie is a text file that the server embeds on the
user’s computer. A cookie is used to identify a user. These cookies are also
used for tracking purpose.PHP supports HTTP cookies. These cookies are usually
set in HTTP header. With the help of PHP you can create and delete the cookie.
a cookie with PHP
function is used to create a cookie. This function has six parameters:
parameter is the name of the cookie and store in environment variable called
is used to store the content of the cookie.
this parameter is not set than cookie will automatically expire when the
browser is closed.
This parameter specifies the directories for which cookie is valid.
cookies are valid for only those host and domain, who had created them.
This can be set to 1 to specify the
secure transmission using HTTPS otherwise set 0 for cookie to be sent by regular HTTP.
setcookie(name, value, expire, path, domain,
singh", time()+3600, "/","", 0);
"35000", time()+3600, "/", "", 0);
echo "Set Cookies"
To modify a cookie use the same name and function setcookie():
raj");//Neha singh is replaced by Raghu raj.
"Cookie is not set.";
"Cookie is set.";
To delete a cookie use setcookie() function with
set the expiration date to one hour ago
"", time() - 3600);//name cookie will be deleted
"Cookie 'name' is deleted.";
Cookie 'name' is deleted.