是会议和饼干同样的事情? [英] Are session and cookies the same thing?
本文介绍了是会议和饼干同样的事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于会话和饼干都用来存储临时数据,它们之间的区别是什么呢?
Since session and cookies are both used to store temporary data, what is the difference between them?
推荐答案
在每个HTTP响应,服务器有机会添加页眉设置Cookie:{cookie的名称} = {cookie-数据}; {cookie的选项}
。
In each HTTP response, the server has the opportunity to add a header Set-Cookie: {cookie-name}={cookie-data}; {cookie-options}
.
该浏览器将在每个后续HTTP请求(或由指定的选项),添加页眉饼干:{cookie的名称} = {cookie的数据}
The browser will, in every subsequent HTTP request (or as specified by the options), add a header Cookie: {cookie-name}={cookie-data}
.
请求#1:
POST /auth/login HTTP/1.1
Host: www.example.com
username=Justice&password=pass1234
回复#1:
HTTP/1.1 307 Temporary Redirect
Set-Cookie: user_id=928
Location: http://www.example.com/dashboard
请求#2:
GET /dashboard HTTP/1.1
Host: www.example.com
Cookie: user_id=928
回复#2:
HTTP/1.1 200 OK
Content-Type: text/html
<html>
<head>...</head>
<body>...</body>
</html>
今后所有申请也将包括饼干
头。
这篇关于是会议和饼干同样的事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文