TestingAPIs is still being built. If something breaks, email support@testingapis.com.

Sets one cookie with explicit attributes

GEThttps://api.testingapis.com/api/cookies/set/{name}/{value}Sign in to see this endpoint's URL

The response includes the exact Set-Cookie header, plus a warning when SameSite=None is used without Secure.

Parameters 7

NameTypeDescription
namerequiredpath · stringCookie name: an RFC 6265 token, 1-64 characters.
valuerequiredpath · stringCookie value, at most 256 characters.
httpOnlyquery · booleanAdds HttpOnly. Default false. Default: false.
securequery · booleanAdds Secure. Default false. Default: false.
sameSitequery · stringlax, strict, none or unspecified (default, attribute omitted).
maxAgequery · integer (int32)Lifetime in seconds, clamped to 0-31536000. Omit for a session cookie; 0 expires it immediately.
pathquery · stringCookie path. Must start with /, at most 128 characters, no ;. Default /. Default: "/".

Responses

200
The cookie and its attributes.
400
Invalid name, value, path or sameSite.

Example

Request
curl -X GET "https://api.testingapis.com/api/cookies/set/theme/dark" \
  -H "X-TestingApis-Key: YOUR_API_KEY"
Response200 OK
Set-Cookie: theme=dark; path=/

{
  "message": "Cookie 'theme' set",
  "cookie": {
    "name": "theme",
    "value": "dark",
    "path": "/",
    "httpOnly": false,
    "secure": false,
    "sameSite": "unspecified",
    "maxAge": null
  },
  "setCookieHeader": "theme=dark; path=/",
  "warning": null
}

Sign in to see the details

The parameters, request and response examples and the live Try it panel for this endpoint are for signed-in members. Accounts are free and take a few seconds to create.