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:

How to clear cookies for one site


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

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:

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


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

Share this

Subscribe to