2

i am working on GWT cookies. I was checking whether the cookie is enabled or not and if not enabled to show gwt popup for which i have written following code:

 if(Cookies.isCookieEnabled())
 .....
 else
 Window.alert("please enable cookies");

but when i disable the cookies in browser and try to run the code nothing is appearing? please can some one suggest me the possible cause for this issue and the solution to fix this?

Thanks.

  • Have you checked for Exceptions in the JavaScript Debugger in the Browser? – thst Mar 20 '15 at 20:25
  • In the browser debugger i am getting this exception: cookiedemo.nocache.js:122 Uncaught SecurityError: Failed to read the 'sessionStorage' property from 'Window': Access is denied for this document. – Mahesh More Mar 23 '15 at 07:02
  • Did this solve your issue? – thst Mar 23 '15 at 21:56
  • @thst: It didnt fix the issue. It seems that for Gwt Code (Complied Java-script) needs the cookie enabled to display or function as needed. – Mahesh More Mar 25 '15 at 03:45
  • Wasn't that the question you wanted to get resolved in the first place? How to find out if the cookies are there? If your call to isCookiesEnabled fails (Exception), there are no cookies, so display the dialog. If it can read the cookies db, cookies are there and you can continue. – thst Mar 26 '15 at 11:48
  • @thst : actually when I disable the cookies it is not going in he code, not even to check whether the cookie is enabled and in the browser not seems to appear to :(. Which made me to think that may be GWT internally needs cookies to start its application. – Mahesh More Mar 30 '15 at 04:48

1 Answers1

0

Catch the exception and pop up the message as if cookies were disabled with propere recognition.

thst
  • 4,592
  • 1
  • 26
  • 40