How to send cookie for authentication with Unirest in Java
<p>As the title says ,i'm trying to send a cookie containing a user id with my get request.Some thing like this:</p>

<pre><code>    BasicCookieStore cookieStore =  new org.apache.http.impl.client.BasicCookieStore();

    cookieStore.addCookie(new BasicClientCookie("UserID",userId));

    Unirest.setHttpClient(org.apache.http.impl.client.HttpClients.custom()
            .setDefaultCookieStore(cookieStore)
            .build());
    com.mashape.unirest.http.HttpResponse&lt;InputStream&gt; responseGet = Unirest.get(someUrl)
            .header("content-type", "*/*")
            .asBinary();
</code></pre>

<p>The problem is in my spring controller for handling the request.It does not receive the cookie.
Any help would be appreciated.Thank you</p>

<p>EDIT
And here is the controller.</p>

<pre><code>@RestController
public class ExcelTest {

@Autowired
private RequestUtils requestUtils;

@RequestMapping(value= "/excelUnmatched", method = RequestMethod.GET)
public void getExcel(HttpServletResponse response, HttpServletRequest request) throws IOException {
    String userId=request.getHeader("UserID");
    Optional&lt;User&gt; user = requestUtils.getUserFromRequest(request);
    Workbook workbook = exportExcel();
    response.setHeader("Text send", "attachment; filename=test.xlsx");
    workbook.write(response.getOutputStream());

}
</code></pre>

<p>The thing is i can put the userID in the header,but because of design constraints i need the userID in a cookie so i can use the getUserFromRequest method.
Thank you again</p>