Sign in Registration

What are cookies and how to clear them in the browser, working with cookies in PHP and JS

Cookies or cookies (pronounced cookies, translated as cookies) are small files in the browser that are capable of storing text data. This is a useful mechanism, without which authorization is impossible on most sites today. Cookies are sent by the server, after which the browser installs them or they are installed via JavaScript (JS).

Sometimes you need to clear cookies - this can be done for all sites at once or only for one specific one. How to do this is shown below, the examples of clearing cookies refer to the browser "Google Chrome", in other browsers everything is the same.

How to clear all cookies


You may need to clear cookies in your browser in different cases, for example, to log out of accounts on different sites. To clear all cookies in the browser , follow these simple steps:

  • go to "Settings";
  • select the "Additional" item;
  • select the "Clear history" item;
  • in the window that appears, select "Cookies and other site data", as well as other items if necessary;
  • click on the "Delete data" button.

How to clear cookies for one site


If you want to clear the data for only one specific site, you need to:

  • open the desired site and click on the icon on the left next to the address bar;
  • select "Cookie Settings";
  • in the window that appears, select the required domain;
  • click on the "Delete" button;
  • click Finish and refresh the page if necessary.

How to work with cookies in PHP

How to work with cookies - how to set or get cookies? For this, the means of the programming language are used. For example, there are special functions for PHP, they are described on the official website in the section - .

Main functions and features:

  • setcookie - sends cookie;
  • setrawcookie - send cookie without url encode value;
  • $ _COOKIE is an array that automatically includes all cookies sent to the server by the visitor's browser. Accordingly, it is easy to get any cookie value from such an array anywhere.

How to work with JavaScript cookies

JavaScript also has accessibility features. The standard document.cookie property is used to read, write and delete cookies. It is a simple string in a special format, so for convenient work you will need additional functions that implement the necessary operations. Third party libraries such as jQuery Cookie are often used.

Sample, how to set, get or delete a cookie on jQuery Cookie :

  // setting cookie
$ .cookie ('name', 'data', {path: '/', expires: 365});

// get cookie
$ .cookie ('name');

// delete cookie
$ .cookie ('name', null, {path: '/'});
// or
$ .removeCookie ('name', {path: '/'});  

So, we found out that cookies are extremely useful for the operation of sites. Deleting or clearing cookies in your browser is very easy, just a few simple steps. Working with cookies in PHP and JavaScript is not difficult, there are special tools for this.

Comments (0)
For commenting sign in or register.

Latest articles

Popular sections

Eqsash (Tools)

Android app - VK LAST USER ID, отучитель от зависимости и т.д.:
Available on Google Play

Amessage (Communication)

Login to the web version
Android app:
Available on Google Play

Share this

Subscribe to



IT notes - In simple language about the most necessary things (HTML, CSS, JavaScript, PHP, databases, Drupal, Bitrix, SEO, domains, security and more), PDF, 500 p.