---
title: ICookieService
summary: API reference for ICookieService.
status: draft
owner: SAIF IT Core Services
last_reviewed: 2026-10-12
library: BolMiddleware
reference_type: package
---

# ICookieService

Contract for reading and writing browser cookies, including whole objects serialized as JSON. `CookieService` implements it.

## Purpose
- Store the `BolContext` cookie and other cookies with a lifetime ([BR-BOLMIDDLEWARE-004](../../business-rules.md#br-bolmiddleware-004-context-cookie-lifetime-and-flags)).

## Context
- Namespace: `BolMiddleware.Services.CookieService`
- Assembly/package: `BolMiddleware`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `SetCookie` | `void SetCookie(string name, string value, int timeout)` | Writes a cookie that expires after the timeout in seconds. |
| `SetCookieObject<T>` | `void SetCookieObject<T>(string name, T value, int timeout)` | Serializes the object and writes it as a cookie. |
| `GetCookie` | `string? GetCookie(string name)` | Reads a cookie value. |
| `GetCookieObject<T>` | `T? GetCookieObject<T>(string name)` | Reads and deserializes a cookie. |
| `DoesCookieExist` | `bool DoesCookieExist(string name)` | Tells whether the request carries the cookie. |
| `DeleteCookie` | `void DeleteCookie(string name)` | Removes the cookie. |

## Behavioral notes
- Registered as scoped.

## Constraints and usage notes
- See the implementation page for cookie flags.

## Sources
- src/BolMiddleware/Services/CookieService/ICookieService.cs
