2012年5月17日

IE 不吃餅乾(Cookies)的問題:避免包含底線「_」(underscore)的網址

包含底線的網址,例如 abc_efg.company.com 雖然也可以用瀏覽器開啟,但是會發生在 Chrome / Firefox 一切正常,但使用 IE 瀏覽器就會無法儲存 Cookie 導致 Session 失效的問題。

從 IEInternals Blog Bugs QA 可以找到以下跟 Cookies 有關的說明:

IE0005: By-design.  Setting cookies fails when the hostname of the server contains an underscore.
IE0006: By-design.  Setting more than 20 50 cookies per host results in the oldest cookie being lost.

因為底線「_」(underscore)對 DNS 的 Domain Name 規範來說,屬於不合法的符號:

以下清單是 DNS 不允許的符號列表,出自微軟的網頁


Disallowed characters
  • comma (,)
  • tilde (~)
  • colon (:)
  • exclamation point (!)
  • at sign (@)
  • number sign (#)
  • dollar sign ($)
  • percent (%)
  • caret (^)
  • ampersand (&)
  • apostrophe (')
  • period (.)
  • parentheses (())
  • braces ({})
  • underscore (_)

如果需要在網址中使用分隔符號,可以用「-」(hyphen)。例如 abc-efg.company.com,就能避免 DNS 規則衝突造成的問題發生。

沒有留言:

張貼留言

lyhcode by lyhcode
歡迎轉載,請務必註明出處!