How does the browser relates the cookies for the websites opened in tabs.for example in firefox i have opened five tabs and in each tab i have loaded different sites. my question is how browser identifies which cookies for which site. what is the relationship it has. similarly if i open the same sites in another browser instance , will the same cookie be used.
Cookies have nothing to do with tabs or windows -- they have to do with requests to a domain. Whenever the browser makes a request to a webserver for a domain, any cookies that it has for that domain will be sent in the request header. Often there are 10s of requests made for each webpage to download the html, images, javascript, etc.. Each of those requests get sent with the cookies for the domain in the request. Here's a good page about how cookies work in case you don't know.
If you have 5 tabs to different webpages then the requests made in those tabs to the various different domains will have different cookies. If some content (for example an image) is shared across all sites, then the same cookie will be sent in all of the 5 requests. If you open the same webpage in another tab in the same browser then the same cookies will be used for requests for that domain.
If you open another browser "instance" then it depends probably on the browser and your OS. If the cookie is not a session cookie, i.e. if the cookie is stored to disk, then when you run another instance of Firefox, it should read/write to the same cookie file as the first instance. Often if you start another browser it may just start another window of your current browser so the cookies will be the same. If you run two different types of browsers then most likely the cookies will be separate although it depends on the browsers on whether they share the same cookie files.