Home Tutorial Php Examples Setting Cookie

 
 

Setting Cookie
Posted on: July 31, 2009 at 12:00 AM
In this example you will learn about setting cookie in PHP.

Setting Cookie 

setcookie function is used for setting up a cookie. In the following example, if you use $_COOKIE command, you will view one cookie value, and if you see print_r ($_COOKIE), you will view all cookie value.

We have set the cookie value for up to one month duration.

<?php
$expire=time()+60*60*24*30;
setcookie("cookie", "Rose India", $expire);
echo $_COOKIE["cookie"]; # view one cookie value
echo "<br/>";
print_r($_COOKIE); # view all cookie value
?>

Related Tags for Setting Cookie:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.