Cookies can be considered as a collection of small files stored in your computer. Don’t get yourself confused with the cookies what’s on the dessert menu. They are not even physical objects in computers world. Cookies plays a very important role which in turn helps you browse the internet – and yes they can cause trouble if you don’t know how to manage them.
What are web cookies ?
A computer cookie or better known as HTTP Cookie, web cookie, internet cookie or a browser cookie, is a term for a message or a packet of data which a computer sends or receives back without changing or altering it over the internet. So in general it can be said that a cookie consists of information. Whenever you visit a website, the website sends a cookie to your browser and your browser stores it in a file on your system.
When are cookies actually created ?
Writing data in a cookie is usually done when you visit a website or more specifically when a submit button is pressed, the data handling page is responsible for storing the data in a cookie. If the user has disabled the cookies in his/her browser, the write cookie operation will fail and the website has to take default action or may prompt user to re-enter data each time the page is loaded.
Why Cookies are used ?
Cookies helps the websites to keep track of your visits and activities. Tracking your activities is not always a bad thing, for example, when you’re on a shopping website and add something to your cart, the item remains in your cart even if you started browsing some other products in the same website. If there are no cookies, the shopping cart would reset to zero, as soon as you clicked on a new link.
Cookies also provides a convenient way to transfer data from one session to another without having to burden the server. Cookies can also be used to record your most recent visit or your login info so that it can keep you logged in the next time you visit the same website. You might have noticed the “Remember Me” or “Keep me logged in” option on various login forms. This is possible only with the help of cookies.
Different types of cookies keep track of different activities. Session cookies are used only when a person is actively navigating a website; once you leave the site, the session cookie disappears. Tracking cookies may be used to create long-term records of multiple visits to the same site. Authentication cookies track whether a user is logged in, and if so, under what name.
How long does a cookie lasts ?
The expiry time of a cookie is set during it’s creation by the server. By default the cookie is destroyed when the browser is closed, but it can be made to live for an arbitrary length of time.
Who can access cookies ?
The visibility of a cookie can be controlled by setting ‘root domain”, it’ll then be available to any URL belonging to that root. For example, the root could be set to “techblogue.com”, then the cookie would be available to the site “www.techblogue.com” or “xyz.techblogue.com” and so.