Monday, April 1, 2013

HTTP cookie

What is a Cookie?
Cookie is also known as HTTP cookie or web cookie or browser cookie. When you access web pages, some data from that webpages store in your browser known as cookie.
OR
Cookies are a mechanism for storing data in the remote browser and thus tracking or identifying return users.
When you Login to some website, then session is stored in cookie.



How to Create a Cookie?
setcookie($name, $value, $expireDateTime, $path, $domain, $secure, $httpOnly);

How to Retrieve a Cookie Value?
echo $_COOKIE[$name];

How to Delete a Cookie?
Cookie can not be deleted. You can delete cookie by providing the expire date in set cookie. For Example
setcookie($name, "", time()-3600);



No comments:

Post a Comment