What is the proper way to send a ‘full’ cookie across a URLConnection?
I’ve been using:
URL url = new URL(page);
URLConnection urlConn = url.openConnection();
urlConn.setRequestProperty("Cookie", myCookie);
urlConn.setUseCaches(true);
urlConn.connect();
The myCookie value is
testCookie=d1lEZk9rSHd3WnpBd2JkWGRhN1RYdz09OkEwQ21pSFJVZzBpVDhhUENaK3ZPV2c9PQ
Is there a way to send the Path,Domain, and Expires with it? Do you need to encode the value in some way?
Well, if you are only setting a cookie I guess you could simply do like:
If you’re setting more than one cookie than you could probably use the
addRequestPropertymethod instead.For the expires attribute make sure to use the format: Weekday, DD-Mon-YY HH:MM:SS GMT.
The only legal time zone is GMT, and the separators between the elements of the date must be
dashes.