Maclean Pinto
Maclean Pinto

Reputation: 1135

How to send cookies over URL connection

I am trying to set Cookies and request headers via URL connection. Here is the client side code

UUID = request.getHeader("UUID");               
conn.addRequestProperty("Cookie", iPlanetDirectoryPro);
conn = url.openConnection();
conn.setDoOutput(true);
objOstr = new OutputStreamWriter(conn.getOutputStream());
objOstr.write(res);

One server side i am trying a retrieve the cookie using "iPlanetDirectoryPro" as the cookie name. But i am getting null. What is the mistake i am doing here?

If i set as conn.addRequestProperty("iPlanetDirectoryPro", iPlanetDirectoryPro); then what is the difference between cookie-and-string-in-request-header https://stackoverflow.com/questions/21226475/difference-between-cookie-and-string-in-request-header

Upvotes: 0

Views: 280

Answers (1)

Shoaib Chikate
Shoaib Chikate

Reputation: 8975

Try using:

  conn.getRequestProperty("Cookies"); 

See the doc.

Upvotes: 1

Related Questions