---
title: "Sets cookies from query parameters and redirects to `/cookies`."
url: "https://developer.rucho.org/apis/rucho/versions/5bdf1bcb-8db4-40f1-a293-72c7198e26c8/operations/set_cookies_handler"
---

> Full API specification: https://developer.rucho.org/apis/rucho/versions/5bdf1bcb-8db4-40f1-a293-72c7198e26c8.md

# Sets cookies from query parameters and redirects to `/cookies`.

`GET` `/cookies/set`

Operation ID: `set_cookies_handler`

Each non-reserved query parameter becomes a `Set-Cookie` response header. Reserved keys add attributes applied to every cookie set in the request: `secure`, `httponly`, `samesite=<Strict|Lax|None>`, `max_age=<seconds>`, `path=<path>` (default `/`), `domain=<domain>`. After setting the cookies, responds with a 302 redirect to `/cookies` so the client can see the result. # Example `GET /cookies/set?session=abc&secure&httponly&samesite=Strict&max_age=3600` sets `session=abc; Path=/; Max-Age=3600; SameSite=Strict; Secure; HttpOnly`.

## Query parameters

- `` (object, required) - Cookie name=value pairs, plus optional attribute flags: secure, httponly, samesite, max_age, path, domain

## Responses

- `302` - Redirects to /cookies after setting cookies

## OpenAPI definition

```yaml
openapi: 3.0.3
info:
  title: rucho
  version: 1.6.0
servers:
  - url: https://rucho.org
    description: Production (EKS us-east-2, behind Kong)
paths:
  /cookies/set:
    get:
      tags:
        - crate::routes::cookies
      summary: Sets cookies from query parameters and redirects to `/cookies`.
      description: >-
        Each non-reserved query parameter becomes a `Set-Cookie` response
        header.

        Reserved keys add attributes applied to every cookie set in the request:

        `secure`, `httponly`, `samesite=<Strict|Lax|None>`, `max_age=<seconds>`,

        `path=<path>` (default `/`), `domain=<domain>`. After setting the
        cookies,

        responds with a 302 redirect to `/cookies` so the client can see the
        result.


        # Example


        `GET
        /cookies/set?session=abc&secure&httponly&samesite=Strict&max_age=3600`

        sets `session=abc; Path=/; Max-Age=3600; SameSite=Strict; Secure;
        HttpOnly`.
      operationId: set_cookies_handler
      parameters:
        - name: ""
          in: query
          description: "Cookie name=value pairs, plus optional attribute flags: secure,
            httponly, samesite, max_age, path, domain"
          required: true
          schema:
            type: object
            additionalProperties:
              type: string
      responses:
        "302":
          description: Redirects to /cookies after setting cookies
```
