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:
The above set cookie can be accessed by: