如何用 JavaScript 建立僅限於會話的 Cookie?
要建立僅限於會話的 Cookie,你需要將 Cookie 的過期日期設定為之後的幾年。你需要設定 expire 屬性 −
current time + 5 years
expire 屬性顯示 Cookie 將過期的日期。如果此項為空,當訪客退出瀏覽器時 Cookie 就會過期。
注意 − 不要考慮移除 expire 值來建立僅限於會話的 Cookie。這不起作用。將 expire 屬性設定為將來的日期。
廣告
要建立僅限於會話的 Cookie,你需要將 Cookie 的過期日期設定為之後的幾年。你需要設定 expire 屬性 −
current time + 5 years
expire 屬性顯示 Cookie 將過期的日期。如果此項為空,當訪客退出瀏覽器時 Cookie 就會過期。
注意 − 不要考慮移除 expire 值來建立僅限於會話的 Cookie。這不起作用。將 expire 屬性設定為將來的日期。