Get Cookies
Retrieves all cookies in the current page session.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.
Input
- Page Id - Id of the browser page to retrieve cookies from. This ID is generated by the Open Browser node.
Output
- Cookies - Retrieved cookies in the current browser session. For versions 24.1.5 and later, cookies are returned as an array of cookie objects with full details (name, value, domain, path, expiry, etc.). For earlier versions, cookies are returned as a simple name-value map.
How It Works
- The node receives the Page ID and validates it is not empty
- It waits for any configured delay before execution
- It retrieves the active page session using the provided Page ID
- The node calls the browser API to get all cookies for the current page
- Based on the Robomotion version:
- Version 24.1.5+: Returns full cookie objects with all properties
- Earlier versions: Returns a simple key-value map of cookie names and values
- The cookies are stored in the output variable
- The node applies any configured delay after execution
Requirements
- An active browser session created by the Open Browser node
- A valid Page ID from the Open Browser node
- The browser page must be loaded and cookies must be set by the website
Error Handling
| Error Code | Description |
|---|---|
| Core.Browser.GetCookies.ErrOnCreate | Configuration parsing error during node creation |
| Core.Browser.GetCookies.OnMessage | Error parsing incoming message data |
| Core.Browser.GetCookies.ErrPageId | Page ID is empty or not provided |
| Core.Browser.GetCookies.ErrSession | Invalid Page ID, session not found, or error retrieving cookies |
| Core.Browser.GetCookies.ErrOutputMarshal | Error serializing output cookies data |
Usage Examples
Example 1: Saving Session Cookies
When you need to save login session cookies for later reuse:
1. Use Open Browser to start a browser session
2. Navigate to a website and complete the login process
3. Use Get Cookies to retrieve all session cookies
4. Store the cookies output in a variable (e.g., sessionCookies)
5. Save the cookies to a file or vault for later use
6. In future sessions, use Set Cookies to restore the session
Example 2: Debugging Cookie Issues
When troubleshooting authentication or session problems:
1. Use Open Browser and navigate to the problematic website
2. Perform the login or action that sets cookies
3. Use Get Cookies to retrieve all cookies
4. Log the cookies to inspect their values
5. Check if required cookies are present and have correct values
6. Verify cookie domains, paths, and expiry dates
Example 3: Transferring Sessions Between Browsers
When you need to transfer a session from one browser to another:
1. Use Open Browser to start first browser (browser1)
2. Complete authentication and establish session
3. Use Get Cookies to extract cookies (cookies1)
4. Use Open Browser to start second browser (browser2)
5. Navigate to the same domain in browser2
6. Use Set Cookies with cookies1 to transfer the session
7. Refresh the page to activate the transferred session
Usage Notes
- Get Cookies retrieves all cookies accessible to the current page
- Cookies are domain-specific and only cookies for the current domain are returned
- HttpOnly cookies (set by the server) are also retrieved
- Secure cookies (HTTPS-only) are included if the page is loaded via HTTPS
- Cookie expiry times are included in version 24.1.5 and later
- The output format differs based on Robomotion version for backward compatibility
- Session cookies (no expiry) are valid only while the browser is open
Tips
- Always navigate to the target domain before getting cookies
- Use Get Cookies after login operations to capture authentication cookies
- Store cookies securely if they contain sensitive session information
- Check cookie expiry dates before reusing saved cookies
- For API integrations, extract specific cookie values using JavaScript or string operations
- Combine with Set Cookies node for session management across browser instances
- Use vaults to securely store authentication cookies between robot runs
- Be aware of cookie scope (domain and path) when working with multiple sites
Related Nodes
- Open Browser - Creates the browser session and Page ID
-
- Sets cookies in a browser session
- Open Link - Navigates to pages where cookies are set
- Run Script - Can be used to manipulate cookies via JavaScript