Cookies and session management
Cookies are important part of session mechanism in the web and when working with APIs. This section describes how to use cookie manager to authenticate the request using cookies.

Introduction video

Session management introduction video
When possible, use other means to authenticate a request like Bearer token with JWT.
Advanced REST Client emulates browser behavior when it comes to handling cookies. When a set-cookie header is received as a response to an API call then the value of the cookie is processed according to HTTP State Management Mechanism specification. When a request is made to the cookie domain after the cookie was received it is automatically added to the request.
The "set-cookie" header tells the client (web browser, ARC) that the server requests to store some data on the client. This data should be then send back with any following request that matches set domain and path.
ARC is web based application and it has a browser included in it. To leverage this ARC allows you to open a Chromium browser window (it is open source version of Chrome), log in to a web service, and store received this way cookies into ARC storage. The window opened in ARC has a separate storage and session management than any other ARC window (main application, menu popup window, task manager, and so on). This way you can securely authenticate in the window and only incoming cookies are sent back to the application ignoring any other stored values.

Authenticating to a web service

To obtain and store cookies by logging in to a web service using a browser window select Request > Web Session > Login to a web service menu option. This opens an URL input where you can put the login page URL.
Login to a web service URL input
In this example we will use MuleSoft's Anypoint platform login scheme. The login page is accessible under https://anypoint.mulesoft.com URL.
Login page to Anypoint platform
After successful login a regular page is rendered.
Authorized user view
Now the login window can be be closed. All cookies sent by the authorization server are now synchronized with ARC's cookies manager. You can see the cookies by selecting Request > Web session > Cookie manager menu option.
Cookies set by the web service
When a request to matching domain is executed the cookies are automatically added to the request.
Request with cookies added automatically

Creating cookies manually

In Cookie manager (Request > Web session > Cookie manager) you have an option to create a cookie manually or to edit existing cookie. I am going to create a new cookie that is going to be set to a request send to domain.com.
Cookie editor with values
After saving the cookie a new entry is added to the list of cookies.
Created cookie on the list of cookies
You can preview cookie details or edit the cookie after pressing "details" button next to cookie name.
Cookie details
After a cookie is set it will be automatically added to a request that matches the domain domain.com.
Request with cookie
Because the cookie was created with dot "." in front of the cookie domain, the cookie is applied to all requests sent to the domain and all its subdomains. This means the request to domain http://www.domain.com will also have the cookie applied to it.
Last modified 7mo ago