What is a Cookie?
A cookie is flat file based system used to represent a user of the website. It is stored on the local computer of the user. When you visit a website a cookie may be set to represent the user. Next time he visits the website, he does not need to identify himself manually; instead the cookie will represent him on that website. With the help of PHP, cookies can be created, read and destroyed.
Why do we use Cookies?
We can literally put 4000 characters of data in a flat cookie file and store information about the user preferences for a particular website. Some of the practical uses of Cookies are as follows:
- Many sites use them to provide customized pages and results to their users. This can be achieved by storing all the information like preferences etc in a cookie.
.
- Many websites use cookies to log their users in automatically. By storing a few pieces of user information they can automatically authenticate the user’s details and use them to save the user time when they log in.
.
- Visitor tracking and statistics systems often use them to track visitors. By assigning the visitor a cookie, they will not be counted more than once, so accurate unique visitor statistics can be obtained.
Cookie Security:
Practically there is no security threat while using cookies. A cookie set by a particular website cannot be accessed or even check if it exists by another website even if it wants to. But since cookie is just a flat text file, it can be opened and read on the computer it is stored in.
If a website has stored a password in a cookie it can be read and this can pose threat to hacking. But if the same password is encrypted using a hash like md5() or sha1() then it can be more secure since this content is used to match it with the password stored on the website.
To read the full article i have written please visit: CLICK HERE