Problem Deleting Cookies

S

sjickells

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top