简体   繁体   English

是否可以判断 GWT 中是否启用了 cookies? 如果不是什么原生 javascript 可以做到这一点?

[英]Is it possible to tell if cookies are enabled in GWT? If not what native javascript can do this?

As the title said...正如标题所说...

Is it possible to tell if cookies are enabled in GWT?是否可以判断 GWT 中是否启用了 cookies? If there is no baked in GWT support what javascript can do this?如果 GWT 中没有出炉支持什么 javascript 可以做到这一点?

If this is not possible I will just do it by checking the http request headers.如果这不可能,我将通过检查 http 请求标头来做到这一点。

You can check navigator.cookieEnabled in browsers that support it.您可以在支持它的浏览器中检查navigator.cookieEnabled

If navigator.cookieEnabled is undefined (instead of true or false) then you can try setting a cookie and retrieving it.如果navigator.cookieEnabled undefined (而不是 true 或 false),那么您可以尝试设置 cookie 并检索它。

edit: Cookies.isCookieEnabled() will return true/false if cookies are enabled -- it does this by setting a cookie and checking if it was set .编辑: Cookies.isCookieEnabled()如果启用 cookies 将返回 true/false - 它通过设置 cookie 并检查它是否已设置来做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM