Discussions

Performance and scalability: Check where the user Accepts the cookie

  1. Check where the user Accepts the cookie (1 messages)

    Hi,
       If I need to check, if the user opted to accepts cookie or not (a setting, which browser user would've set), how do I acheive this using Java. I know to do the same using javascipt. but let me know if this is achievable using Java.

    Thanks in advance
    Veena
  2. I believe you can just do this, in your servlet, using the HttpServletRequest object.

    if(request.getCookies() == null) {
     // cookies are not enabled, redirect to error page or whatever you want to do
     ...
    }

    You could also try:

    // if true, then cookies are not enabled because the session id is in URL
    if (request.isRequestedSessionIdFromURL() )

    Bill Lasley
    Versant Corp.
    http://www.versant.com