Problem Deleting Cookies

Discussion in 'Java' started by sjickells@gmail.com, Feb 23, 2005.

  1. Guest

    Can anyone help?

    I have written a servlet to delete cookies. but it seems not to be
    deleting them or only deleting a few of the cookies but not all of
    them. Below is an example of my code :

    //Set Print Writer
    PrintWriter pout = resp.getWriter();

    //Get cookie array from HttpServletRequest
    Cookie[] cookieArray = req.getCookies();

    //Guard statement to check for missing cookies
    if (cookieArray != null)
    {
    // Print a list of all cookies sent by browser
    for (int i =0; i< cookieArray.length; i++)
    {
    Cookie c = cookieArray;

    String cname = c.getName();

    //Expire the cookie immediately
    c.setMaxAge( 0 );

    //Send cookie back to the browser to void it
    resp.addCookie(c);

    pout.println (cname + " Deleted");
    }
    }
    else
    {
    pout.println ("No cookies present, or browser does not support
    cookies");
    }

    But when I check to see if the cookies are there using another servlet
    I get the following

    Name : LtpaToken
    Value:
    yGhHRpWBEH5JxzX5baIzbnS+umxDAJUa9AEYyJY03F7FUiZQMwmWtac8/vpl8gEMlJrgpTNJuhY+s75mlOIpq9C9O1ujhpDDOapocdR+TAiCoXItYxCyfDmIfPeis01sc/c7gAan0tB9fgX1hdWXacKRNPPwuglZ6r9pg8MVqzm4qaQr3SEAm8tQSOs68bHphbStagLlZ4Wj7bhEGfqiDo9mq2F2F2rZlJ3E7OYsQSS7gq+i39r5Ga3e3UHRERhNlZsp6XjPp6ybk0UWRLo3bvMeU0QIAeDNHfxiFreJL9FQETt4MWc+T/cAcMqDm57jZGPxXu8NlcL25Z6TBYKsM8XeogQYFIahZN1uk6Nf/hxsUSQtUL4XZaLnwlhPCyhYx/rlVl6gS4UwySS7+ZrSEs9tIG6nbODC
    Comment: null
    Domain: null
    Age: -1
    Path: null
    Version: 0
    Unsecure cookie

    Name : ONTCred
    Value:
    xS4YpHZxbyr2jHTNb2YF2zCF0zz0H2o6F3sHOOs6VCgGga1e8Yf27lwarbuuK12l//jOtXmJtkUKplSr3eIoG7puJTbzpQ3PPrE5cc8mWMoeIZCQrMgA66Nr9l2zKqNujtWWJXT1S6HzBXGuKsNj+f1uEVz7K26wU6qU0VqI4JndhU6crT2FJBXK2q7PprNDpaeZ8tfCThKih1Q6ZYyfRELQ6KwN1zfcAAAAAAAAAAA=
    Comment: null
    Domain: null
    Age: -1
    Path: null
    Version: 0
    Unsecure cookie

    The two cookies above are the main ones I am having problems with.

    Anyone any ideas why the cookies are not expiring?
     
    , Feb 23, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michal A. Valasek

    Problem with deleting cookies

    Michal A. Valasek, Jul 25, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    468
    Peter O'Reilly
    Jul 25, 2003
  2. macro
    Replies:
    4
    Views:
    5,117
    macro
    Mar 29, 2006
  3. Harry Barker
    Replies:
    2
    Views:
    546
    Alf P. Steinbach
    Apr 19, 2006
  4. _Who
    Replies:
    7
    Views:
    2,778
  5. crea
    Replies:
    2
    Views:
    443
    Nobody
    Dec 28, 2012
Loading...

Share This Page