views:

80

answers:

4

On websites where you have to enter a user name and password, I notice that I can browse the site with one browser and it will know who I am no matter where I go on the site. But if I open a different browser it doesn't know who I am in that browser unless I log on in that browser.

After I log in to a website, does it store some kind of cookie in my browser, and every time I navigate to a different page on that site, it checks the cookie for my identity?

What would happen if I logged in, and then before browsing to a different page on the site, deleted the cookie?

+2  A: 

After I log in to a website, does it store some kind of cookie in my browser, and every time I navigate to a different page on that site, it checks the cookie for my identity?

Yes. The cookie is sent with each HTTP request.

What would happen if I logged in, and then before browsing to a different page on the site, deleted the cookie?

The same as if you were to switch browsers.

David Dorward
How is the cookie put into the request? Is information from inside the cookie appended to the html address?
Phenom
@Phenom Use wireshark or an HTTP proxy to study the details, but the breakdown is this: The HTTP request contains both the URL ("html address") and all cookies the web browser has in store for this specific domain and URL path. For details, see http://en.wikipedia.org/wiki/HTTP_Cookie#Setting_a_cookie
phihag
It is an HTTP header. The spec is at http://www.ietf.org/rfc/rfc2109.txt
David Dorward
+1  A: 

Every time when you navigate a new page, your browser sends a request to the server and the server sends back you the response. Your request contains the cookies, which the server can parse and use. You if you delete the cookie, your browser can't send it with the next request.

Roland Soós
How is the cookie put into the request? Is information from inside the cookie appended to the html address?
Phenom
Your browser stores it. Cookies has name, value, domain, path, expiration. When you navigate a site, your browser sends the cookies, which allowed for that site.
Roland Soós
+2  A: 

This is more of a "teach a man to fish" answer, so I apologise if it's not what you were after. But if you take my advice you will learn lots, so please trust me :)

There's a number of tools that you can use to track exactly what http traffic is going between your browser and the server. One is called Firebug, a plugin for Firefox. The other kind of tool is called a "web debugging proxy". There's charles, which is very powerful, and fiddler, which is free.

CharlesProxy

What you want to do with any of these tools is use a website, and then look at the raw request. This shows you exactly what your browser is saying to the server. You'll see the cookies for that server are sent along with every request. What's cool about these tools is that you can edit a request just before it's sent, so you can test how the servers respond...

Rob Fonseca-Ensor
Thanks, just installed firebug. How do I see it with firebug?
Phenom
once you turn on firebug (by clicking on the ladybug), open the "net" tab. This shows all http requests (images, css, html etc). Click on the html request, and you'll be able to drill into the request headers
Rob Fonseca-Ensor
A: 

What would happen if I logged in, and then before browsing to a different page on the site, deleted the cookie?

You would no longer be logged in.

After I log in to a website, does it store some kind of cookie in my browser, and every time I navigate to a different page on that site, it checks the cookie for my identity?

Yes. Most likely, you are dealing with a "session-cookie". These cookies do not store any information themselves, but use a long string to identify yourself to a server. I would suggest doing some research on cookies. As for the (I'm guessing assumed) question of "Why cookies work on different pages?" is because cookies are tied to the domain, and not the exact URI.

Cookies contain names, values, and expirations (along with a few others). The most common you'll see are sessions, which use an identifier to load a session-state from the server containing your information. These are the safest cookies as everything is centralized and not as prone to hijacking. The other kind is a regular cookie, which has a limited size and stores information client-side. Anything that has to do with shopping or anything that tracks users most likely uses sessions, while something like a customizable javascript-y page probably uses a normal cookie. The former tracks information server-side for additional security, while the latter poses no security risk, and leaves the information for the client to manage.

Matt