A cookie, also known as a web cookie, browser cookie, and HTTP cookie, is a piece of text stored on a user’s computer by their web browser. A cookie can be used for authentication, storing site preferences, shopping cart contents, the identifier for a server-based session, or anything else that can be accomplished through storing text data.
Cookie can have up to seven parameters but mostly first three are used.
The first 3 parameters are:
1. name: refers to cookie name e.g. cookname
2. value: refers to cookie value stored in cookie name e.g. $_COOKIE['cookname'] => ‘cookvalue’
3. expire: refers to time the cookie expires, if omitted cookie expires on browser close e.g. time()+60*60*24*1 – this time will set the cookie to expire in 1day.
Combining the parameters, cookie set command becomes:
setcookie('cookie_username','username_value', time()+60*60*24*1); The above set cookie can be accessed by:
echo $_COOKIE'cookie_username'];

Posted in
Tags: 








This is EXTREMELY INSECURE. Nobody should use this method to remember a login. Every major browser provides you the ability to manually edit cookies, and an attacked would have a very easy time forcing their way into your site if you use this method.
This is bad, amateur advice, and very irresponsible.