What does it consist of?
A cookie is a data package that a web browser automatically stores on a user's computer when visiting a web page. The cookie is sent from the server to the website visitor. Later, each time the user visits that same web page or any other from the same domain, the web browser will read the cookie, without modifying it, and return it to the web server.
Therefore, a cookie is just data that is stored on the user's computer. Cookies are not software, they are not code snippets, they are just data. Therefore, in principle, cookies cannot transmit and execute viruses, or install malware such as Trojans or spyware.
What is it for?
Cookies are commonly used by web servers to differentiate users and act differently depending on them.
Users are generally identified by entering their credentials on a validation page; Cookies allow the server to know that the user is already validated and, therefore, they can be allowed to access services or perform operations that are restricted to unidentified users.
How do I include it on the web?