Wednesday, December 15, 2021

What is cookie? | Working of Cookie | Purpose of Cookie | Third party cookie | Elements of Cookie

(Note: Watch animated video of cookie, before read this content. – Click here)


Cookies are just files or strings, not executable programs. Cookies are small piece of data which is stored in text file. Cookies are stored data like username and password. Cookies are used to identify your computer when you are using a network. Specific cookies known as HTTP cookies are used to identify specific users and improve your web browsing experience. Cookies are created by server and client’s information is stored. The data inside cookie is labelled with a unique ID to identify each user on internet. When client and server exchange the cookie, the server reads the unique ID from the cookie file and knows what information to specifically server to you.

Purpose of Web Cookie

A cookie is often used to identify a user. Its purpose is to remember information about client, similar to a preference file created by a software. While cookie server many functions, their most common purpose is to store login information for a specific site.


Working of Cookie

Web is basically stateless. Browser sends a request to a server and get back a file. Then the server forgets that it has ever seen that particular client. When a client requests a web page, the server can supply additional information along with the requested page. This information may include a cookie, which is a small text file. Using the cookie server can identify the client. With PHP, you can both create and retrieve cookie values. A cookie is created with the setcookie() function. Only the name parameter is required.


Where does the cookie store?

Browser’s store offered cookies in a cookie’s directory on the client’s hard disk unless the user has disabled cookies.


Elements of Cookie

A cookie contains up to seven fields: Name, Content, Domain, Path, Secure, Create, Expire.

Name: Name of Cookie file.

Content: Server can store anything inside the content of cookie. Sometimes it must be unique ID of the user.

Domain: It tells where the cookies came from. Browsers are supposed to check that servers are not lying about their domain.

Path: Path means server’s directory structure that identifies which part of the server’s file tree may use the cookies. root: path = /

Secure: It means browser may only return the cookie to a secure server. This feature is used for e-commerce, banking and other secure application.

Create: Create means at which time cookie has been created.

Expire: The expires field specifies when the cookies expire. If this field is absent, it means it’s called non-persistent cookie. Otherwise, time and date are available, it means persistent cookie.


What does cookie store?

Cookie is often store settings of website. When user return to that website, the browser sends a cookie that belongs to the website. It allows the website to display information as per your customized setting. Also, cookie stored following items:

Language of website which was selected by user.

At what time user visited website.

If website is e-commerce, then cookie is stored item to be stored in shopping basket.

All the links clicked on that website.


Third Party Cookie

A third-party cookie is placed on a website by someone other than the owner (a third party) and collects user data for the third party. As with standard cookies, third-party cookies are placed so that a site can remember something about the user at a later time.

How do I block third party cookie?

In Settings, go to Cookies and site permissions on the left. On the right, click on Manage and delete cookies and site data under the Cookies and data stored section. On the next page, turn on or off the Block third-party cookies option for what you want.

To learn more about Cookie, Click here

Watch more videos click here.

No comments:

Post a Comment