更新时间:2023-11-28 11:33:10
这三者并不相互排斥.
隐藏输入只是发送给客户端的 HTML.它不会出现在最终用户的页面上,但客户端可以完全访问它.这意味着用户可以通过使用浏览器中的查看源功能看到它(就像他们可以看到来自您的服务器的任何 HTTP 响应一样).
A hidden input is just HTML sent to the client. It does not appear on the page to the end-user, but it is entirely accessible to the client. Meaning that the user can see it (just as they can see any HTTP response from your server) by using the View Source feature in their browser.
cookie 只是另一个由 cookie 名称/值对组成的 HTTP 标头,可以在每个请求/响应中在客户端和服务器之间来回发送.最终用户也可以通过检查浏览器开发者工具中的 HTTP 标头来看到这一点.
A cookie is just another HTTP header consisting of a cookie name/value pair, that can be sent back and forth between the client and server in every request/response. This is also visible to the end-user by checking the HTTP headers from their browser's developer tools.
会话这个术语本身是可疑的,因为可以有客户端会话(存储在客户端的浏览器中,就像 HTML5 Sessions) 或者它可以是服务器端会话.
The term session, on its own, is dubious, because there can be client-side sessions (stored in the client's browser like with HTML5 Sessions) or it can be a server-side session.
在 PHP 中,您可能指的 会话函数 将会话数据存储在服务器上,但只向与他们的会话相关联的客户端发送一个标识符.这是 session_id
,通常作为 cookie 发送回客户端.
In PHP, the session functions that you're probably referring to store the session data on the server, but send only an identifier to the client that is associated with their session. This is the session_id
that is usually sent back to the client as a cookie.
这三样东西通常一起协同工作来做各种事情.所以问哪个更好,就像问我的车哪个部分更好;发动机、车轮还是转向柱?
All three of these things typically work together in conjunction to do various things. So asking, which is better, is like asking which part of my car is better; the engine, the wheels, or the steering column?
为了知道某事如何更好,您必须能够将其与其他事物联系起来.否则,这个问题毫无意义.
In order to know how something is better you must be able to relate it to something else. Otherwise, the question makes no sense.
如果你问什么时候使用这些东西是合适的,那么答案取决于你的需求是什么.
If you're asking when it would be appropriate to use things and for what then the answer depends on what your needs are.
当问题从哪个更好"变为每种方法的用途"时,答案通常开始变得更有意义,因为您将很可能全部使用.
When the question changes from "which is better" to "what are the uses of each" the answers generally start to become a lot more meaningful, because you will more than likely use all of them.