How to use Cookies in PHP

In the starting Cookies were not in common use but this is very common to use Cookies now a days.

Cookies allow the us to store information about the site visitor on their computer to be accessed again the next time they visit. One common use of cookies is to store your username and password on your computer so you don’t need to login again each time you visit a website. Cookies can also store other things such as your name, last visit, shopping cart contents, etc.

Cookies are just like sessions.The main difference between a cookie and a session is that a cookie is stored on your computer, and a session is not. Although cookies have been around for many years but sessions can be stored only for a perticular user session and when user leave a site or close the browser sessions gets destroy. Cookies and sessions can be removed by the user at any time, so don’t use them to store anything too important.

Read the rest of this entry »