Class CookiePolicy

java.lang.Object
com.azure.core.http.policy.CookiePolicy
All Implemented Interfaces:
HttpPipelinePolicy

public class CookiePolicy extends Object implements HttpPipelinePolicy

The CookiePolicy class is an implementation of the HttpPipelinePolicy interface. This policy is used to handle cookies in HTTP requests and responses.

This class stores cookies from the "Set-Cookie" header of the HTTP response and adds them to subsequent HTTP requests. This is useful for maintaining session information or other stateful information across multiple requests to the same server.

Code sample:

In this example, a CookiePolicy is constructed. The policy can then be added to a pipeline. Any cookies set by the server in the response to a request by the pipeline will be stored by the CookiePolicy and added to subsequent requests to the same server.

 CookiePolicy cookiePolicy = new CookiePolicy();
 
See Also: