*/
public void setCookie (Cookie cookie, String domain)
{
String path;
Vector cookies;
Cookie probe;
if (null != cookie.getDomain ())
domain = cookie.getDomain ();
path = cookie.getPath ();
if (null == mCookieJar)
mCookieJar = new Hashtable (); // turn on cookie processing
cookies = (Vector)mCookieJar.get (domain);
if (null != cookies)
{
boolean found = false;
for (int j = 0; j < cookies.size (); j++)
{
probe = (Cookie)cookies.elementAt (j);
if (probe.getName ().equalsIgnoreCase (cookie.getName ()))
{
// we keep paths sorted most specific to least
if (probe.getPath ().equals (path))
{
cookies.setElementAt (cookie, j); // replace
found = true;
break;
}
else if (path.startsWith (probe.getPath ()))
{
cookies.insertElementAt (cookie, j);
found = true;
break;
}