How cookies work?

前端 未结 6 1808
北荒
北荒 2020-11-29 04:35

I wanted to know the interactions of a browser (i.e. Firefox ) and a website.

When I submit my user name and password to the login form, what happens? I think that we

6条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 05:11

    Usually the cookie contains a session id number. The id number is then connected to session data that is stored on the server. The usual process is then:

    1. Send login form
    2. Server checks username and password
    3. If correct, the username is stored in a session file on the server, along with various other useful information about the user (if it's a site admin, moderator, userid and so on).
    4. The server sends back a cookie containing an id number that identifies the session file
    5. The browser sends the cookie with each request to that server, so the server can open the session file and read the saved data.

    Usually the password is not sent more than once (at login in step 1).

提交回复
热议问题