隱藏欄位介紹 & stateless protocol v.s. stateful protocol

這篇介紹隱藏欄位<input type="hidden">,

HTML 表單隱藏欄位 input type=hidden:
http://www.webtech.tw/info.php?tid=96

整篇都建議看看。



另外也可參考這篇的解答,

Original purpose of <input type=“hidden”>?
http://stackoverflow.com/questions/16293741/original-purpose-of-input-type-hidden

擷取重點如下:

type=hidden

--> These fields should not be rendered and provide a means for servers to store state information with a form.

--> This will be passed back to the server when the form is submitted, using the name/value pair defined by the corresponding attributes.

--> This is a work around for the statelessness of HTTP.

--> Another approach is to use HTTP "Cookies".



再者, 因為提到隱藏欄位, 就需要了解一下stateless protocol & stateful protocol:

這篇講到這兩者的定義,

Stateless Protocol
https://www.techopedia.com/definition/697/stateless-protocol

擷取重點如下:

1. A stateless protocol is a protocol in which each particular communication is handled as an independent event, unrelated to other similar communications.

2. The opposite of stateless protocol is a stateful protocol, where an individual communication is handled as part of a greater set of communications.



另外, 這篇是上面這篇的詳細解釋, 也比較更容易懂兩者用途和差異,

[ASP.NET]Stateful與Stateless
https://dotblogs.com.tw/jimmyyu/2010/10/16/difference-between-stateful-and-stateless

整篇都可以看看, 滿簡明易懂的。



最後, 說明如果要使用stateless protocol要使用什麼方法; 如果要使用stateful protocol要用什麼方法,

Why say that HTTP is a stateless protocol?
http://stackoverflow.com/questions/13200152/why-say-that-http-is-a-stateless-protocol

擷取重點如下:

用stateless protocol時:

HTTP is a stateless protocol. A stateless protocol does not require the server to retain information or status about each user for the duration of multiple requests.


用stateful protocol時:

But some web applications may have to track the user's progress from page to page, for example when a web server is required to customize the content of a web page for a user. Solutions for these cases include:

--> the use of HTTP cookies.

--> server side sessions,

--> hidden variables (when the current page contains a form), and

--> URL-rewriting using URI-encoded parameters, e.g., /index.php?session_id=some_unique_session_code.



留言

熱門文章