Session vs Cookie, what’s the difference?

Asked

Viewed 37 times

0

I have a question on Sessions and Cookies on the Node, regarding where they are stored and how it works.

At first I know the following statements:

  1. Cookies I can set when time it can save your data;
  2. Session stores data while the browser is open;
  3. Cookies on the customer’s side;
  4. Session is on the server side;
  5. Session stays inside the Cookie.

Then the following questions arise:

  1. As Browse and/or server knows that the user has already logged in and does not need log back in ?
  2. If Session is within the Cookie why is there such a difference ?
  3. Where is the cookie stored? In our browser ?

I use the Passport however it does everything alone, I wanted to better understand how it works behind the cloths.

  • The question is wide too. And to tell the truth the duplicate nowadays would be closed

  • 1

    @Maniero I did not find answers about my questions, but all right. Thank you

  • 3

    Session stays inside the cookie? This statement is wrong, the cookie is a key that the server uses to rescue the client’s Session in its memory, or in an external database/server.

  • 3

    Because the questions start from wrong premises, then it is better to understand what this is before having a specific and real doubt.

  • 3

    About the claims: 1 you can ask for browser, does not mean it will obey. 2 The session commonly does not stay in the browser, only an identifier of it (a unique value). 3 is that. 4 is usually that. 5 No, a session identifier can be passed by several other ways, cookie is just one of them. About the questions: 1 the browser does not know and does not engage in the login process of your application. 2 it does not stay, 3 stays in the browser while the user or the browser itself does not clean. Access the link for more details

  • @user140828 when we see a request and enter the cookie, there is a 'variable' with all the Infos.. pq ?

  • 1

    People think they understand HTTP, but they don’t, and this is where the kinds of doubts and even confusions arise about what is session, what is front, what is back, how communication actually occurs and has many that us (to me to you to anyone) teach wrong because they did not want to learn right, then you get false information and get this lack of understanding, HTTP is the basis of all communication here, of course q we can cite alternatives for sessions still yes the transport is done by HTTP and on the client side nothing more than such variables are only keys, values are elsewhere.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.