Php Send Cookie Function

What is Setcookie Function?

Explanation

The "setcookie" function is used to send a cookie.

Syntax:


setcookie(name,value,expire,path,domain,secure)

In the above syntax "name" specifies the name of the cookie, "value" specifies the value of the cookie, "expire" specifies when the cookie expires, "path" specifies the server path of the cookie, "domain" specifies the domain name of the cookie,"secure" specifes whether a cookie should be transmitted or not over a secure connection.

Example :


<?php
$value = "this cookie value";
setcookie("TestCookie",$value, time()+3600*24);
?>

In the above example a string is assigned to the cookie, and the cookie is set a expiry time of 24 hours.

PHP Topics


Ask Questions

Ask Question