Share on Google+Share on Google+

Setting Cookie

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.

setcookie("cookie", "Rose India", $expire);
echo $_COOKIE["cookie"]; # view one cookie value
echo "<br/>";
print_r($_COOKIE); # view all cookie value


Posted on: July 31, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.