A cookie is used for identification purposes. It is more commonly used to identify a user in a session. It is a small file the application inserts on the users computer. With PHP one can create and retrieve the cookie.
Cookies in PHP can be set using the setcookie() function. This must appear before the HTML tag.
Syntax:
Setcookie(name, value, expire, path, domain);
The cookie that is set can be retrieved as shown below:
Echo $_cookie[“user”];
Cookies can be deleted either by the client or by the server. Clients can easily delete the cookies by locating the Cookies folder on their system and deleting them. The Server can delete the cookies in two ways:
1. Reset a cookie by specifying expiry time
2. Reset a cookie by specifying its name only
Persistent Cookie
Cookies are used to remember the users. Content of a Persistent cookie remains unchanged even when the browser is closed. ‘Remember me’ generally used for login is the best example for Persistent Cookie.
Monday, September 14, 2009
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment