What is the difference between a Session and a Cookie?

后端 未结 8 2158

What is the difference between a Session and a Cookie?

What circumstances should each be used?

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-01 10:56

    Sessions are not reliant on the user allowing a cookie. They work instead like a token allowing access and passing information while the user has their browser open. The problem with sessions is that when you close your browser you also lose the session. So, if you had a site requiring a login, this couldn't be saved as a session like it could as a cookie, and the user would be forced to re-login every time they visit.

提交回复
热议问题