What are the Types of Cookies on Internet?

What are Cookies & Types of Cookies on Internet?

Cookie is basically a small file that is used to identify a user, this file is stored / embed by the server in the user’s computer. Each time if the same computer requests for a page with a browser, it will send the cookie too. With the help of PHP you can both create & retrieve cookie values. That can be applied on the website interms of cookie consent popup generator

Types of Cookies

There are 2 types of Cookies that are available on internet are:

  1. Session Based
  2. Persistent Cookies

Session Based Cookies

Session based cookies are those cookies, that gets expire when the session is done & you close the window of the website. This means that when you close the tab, the session ends & the cookie is deleted.

Persistent Cookies

Whereas persistent cookies are exactly opposite of the session based cookies, because these cookies don’t get expired when the session ends or the tab of the browser closes.

  • Session cookie is created that when you are navigated to a website or a portion of a website. The session cookie is created when you use the personal login to access the secure pages of a website.
  • Depending on the browser setting its upto you to accept or deny the session cookie. In case if you deny to that, you may have trouble using that website that is dependant on that cookie.

PHP provided a function to set a cookie is setcookie(). This requires upto 6 arguments & it must be called before <html> tag.

setcookie(name, value, expire, path, domain, security);

You can also get the cookie consent for your website from here


Explanation of the arguments


This arguments basically sets the name of the cookie file that will be stored in the users system.


This argument stores the value of the variable & is the content that you really want to store in your computer


This argument specifies the future time seconds since the 00:00:00 GMT on 1st Jan 1970. After this time the cookie will be inaccessible. If this particular parameter is not set then cookie will automatically gets expired when the tab of the web browser is closed


This argument specifies the directories for which the cookie is valid. A forward slash (/) shows that this cookie is valid for all the directories


This argument is used to specify the domain name in very large domains & it must contain at least two periods to be valid. All those cookies must be valid for the host & domain that was created.


This argument shows this can be set to 1 to show that the cookie should only be sent by the secure transmission using the SSL (https) otherwise its priority should set to 0 which mean cookie can be sent by the regular hhtp.


1. What are cookies PHP?

Ans: A cookie is used to identify a user & its a small file that is stored in the user’s system when it used to search for something.

2.Is set cookie PHP?

Ans: To set the cookie in PHP there is a function used setcookie()

3.What is cookie explain with examples?

Ans: Cookies are the main & most common way to track the user’s website’s activities.