Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem Deleting Cookies

Thread Tools

Problem Deleting Cookies
Posts: n/a
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[i];

String cname = c.getName();

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

//Send cookie back to the browser to void it

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

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

Name : LtpaToken
yGhHRpWBEH5JxzX5baIzbnS+umxDAJUa9AEYyJY03F7FUiZQMw mWtac8/vpl8gEMlJrgpTNJuhY+s75mlOIpq9C9O1ujhpDDOapocdR+TAi CoXItYxCyfDmIfPeis01sc/c7gAan0tB9fgX1hdWXacKRNPPwuglZ6r9pg8MVqzm4qaQr3SEA m8tQSOs68bHphbStagLlZ4Wj7bhEGfqiDo9mq2F2F2rZlJ3E7O YsQSS7gq+i39r5Ga3e3UHRERhNlZsp6XjPp6ybk0UWRLo3bvMe U0QIAeDNHfxiFreJL9FQETt4MWc+T/cAcMqDm57jZGPxXu8NlcL25Z6TBYKsM8XeogQYFIahZN1uk6Nf/hxsUSQtUL4XZaLnwlhPCyhYx/rlVl6gS4UwySS7+ZrSEs9tIG6nbODC
Comment: null
Domain: null
Age: -1
Path: null
Version: 0
Unsecure cookie

Name : ONTCred
xS4YpHZxbyr2jHTNb2YF2zCF0zz0H2o6F3sHOOs6VCgGga1e8Y f27lwarbuuK12l//jOtXmJtkUKplSr3eIoG7puJTbzpQ3PPrE5cc8mWMoeIZCQrMgA 66Nr9l2zKqNujtWWJXT1S6HzBXGuKsNj+f1uEVz7K26wU6qU0V qI4JndhU6crT2FJBXK2q7PprNDpaeZ8tfCThKih1Q6ZYyfRELQ 6KwN1zfcAAAAAAAAAAA=
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?

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting data from the file without deleting the file first crea C++ 2 12-28-2012 11:50 PM
Give Request.Cookies and Response.Cookies is there any reason to use another method to use cookies? _Who ASP .Net 7 09-18-2008 07:49 PM
Deleting a File from Hardrive and Deleting a SubKey in Registry Harry Barker C++ 2 04-19-2006 09:34 AM
HttpWebRequest / CookieContainer - not deleting cookies. macro ASP .Net 4 03-29-2006 07:48 PM
Problem with deleting cookies Michal A. Valasek ASP .Net 1 07-25-2003 05:33 PM