Firefox stores cookies in sqlite database, ~/.mozzila/firefox/weired_looking_name/cookies.sqlite . Let's have a look at this database. Some other browser might use xml file to store cookies.
This database has one table moz_cookies; its schema (or what is stored in each line in this table) is following
id INTEGER PRIMARY KEY, baseDomain TEXT, appId INTEGER DEFAULT 0, inBrowserElement INTEGER DEFAULT 0, name TEXT, value TEXT, host TEXT, path TEXT, expiry INTEGER, lastAccessed INTEGER, creationTime INTEGER, isSecure INTEGER, isHttpOnly INTEGER, (..some other sql related stuff ...).
Let's take out one entry which looks like this
88437|
guardian.co.uk|0|0|s_vi|[CS]v1|282093D0050118E3-40220010E20222C9F[CE]|.
guardian.co.uk|/|1436681754|1373609999761418|1369499620403843|0|0
Moodle stored following cookie
64253|
iitb.ac.in|0|0|MOODLEID1_|%25E7%15E6%25FE%25DF%25E3%112Bk%25B1|
moodle.iitb.ac.in|/|1399919851|1188735851803123|1372732221802223|0|0
Now the information stored on my browser as cookie by guardian site will be used by the site when I visit them again. When I visit guardian again, it demands cookies with its `domainName` from browser. This information is sent to site to do whatever it wants to do with it.
By looking at cookies, sites figure out how many new unique visitors they have. They can also check if you logged-out from their site before leaving it; if not then they will automatically log you in during your next visit. Once in a while it is a good idea to look at your cookies if you browse
untrusted sites (porn sites, free download sites etc). I am not aware if
sites can store anything damaging in my browser as cookies.
Cookies are sensitive data and should be protected (please don't share your whole C: on DC) . Now if you insert this cookie in your browser database, and access guardian site, it will take you as me and might give you my already logged-in account -- (I have changed some data, just to be safe).
Prefer private browsing in Firefox on shared computer (such as pc lab), it will delete all cookies as soon as you log-out.