Cookies – PHP
What are cookies in PHP?
Cookies are small files which are stored on user computers. Every time you visit a site on web browser a cookie file gets embed on your system. Next time, when you visit the same web page again, with the help of cookie your saved preferences, settings and personal details for e.g Name, city, Country etc information will be retrieved fro these file.
With the help of PHP we can create and retrieve cookies from the user system.
There are 2 types of cookies in PHP
1. Persistent Cookies
2. Non-Persistent Cookies
What does Persistent Cookie mean?
A persistent cookie is a data file capable of providing websites with user preferences, settings and information for future visits. Persistent cookies enhances the user experience (UX) by rapid access to familiar objects which are stored in cookie created earlier.
When users visit a website and set choices or preferences, persistent cookies may be used to remember these options. Persistent cookies can help isolate and identify a specific client and are capable of traversing a user’s path toward a website. They are stored as text files on the hard drive of a computer and usually have expiration dates of one to two years.
Persistent cookies facilitate setting the following preferences:
- Favorites or internal bookmarks
- User authentication
- Login details
- Menu preferences
- Theme selection, if applicable
- Language preferences
Persistent cookies are also capable of providing the browsing behavior of users.
What does Non persistent means?
These cookies are saved only till the time your web browser is running. As you close your web browser these cookies get deleted. they wont get saved on your system or hard disk.
Third-party cookies are cookies added by a domain that is not the domain you are currently visiting. The most common use of third-party cookies is to track users who click on advertisements and associate them with the referring domain.
For example, when you click on an ad on a website, a third-party cookie is used to associate your traffic with the site where the ad appeared.
While cookies are a necessary part of the modern web, they can also pose a considerable risk of invasion of privacy as well as a security risk to the websites that use them.
Is there any other kind of cookie?
Yes, There are more cookies beside above i.e