Cookie

モジュール概要

HTTP cookie helpers.

チュートリアル

最初に以下の最小例でモジュール利用方法を確認し、その後 API リファレンスを参照してください。

from nexom.app.cookie import *

# このモジュールの関数・クラスを用途に合わせて呼び出します。
# 下の API リファレンスで各関数の引数と使い方を確認してください。

運用チェックリスト

  • 本番では例外処理を必ず実装し、戻り値の型を固定してください。
  • 引数のデフォルト値と必須/任意を仕様書としてチーム内で固定してください。
  • ログと監視を追加し、エラー時の復旧手順を運用Runbookに記載してください。

API リファレンス(全関数・全メソッド)

クラス

Cookie

分類: public class

Represents a single HTTP cookie.

Cookie の全メソッド

__init__

分類: special method

シグネチャ
__init__(self, name: str, value: str, *, http_only: bool = True, secure: bool = True, **kwargs: str | int | None) -> None
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • name / kind=positional-or-keyword / type=str / 必須 / default=なし
  • value / kind=positional-or-keyword / type=str / 必須 / default=なし
  • http_only / kind=keyword-only / type=bool / 任意 / default=True
  • secure / kind=keyword-only / type=bool / 任意 / default=True
  • kwargs / kind=variadic-keyword(**kwargs) / type=str | int | None / 必須 / default=なし
戻り値

None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.cookie import Cookie

obj = Cookie(name="sample", value="sample", http_only=True, secure=True)
__repr__

分類: special method

シグネチャ
__repr__(self) -> str
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • 引数なし
戻り値

str

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.cookie import Cookie

obj = Cookie(...)
result = obj.__repr__()
print(result)
__str__

分類: special method

シグネチャ
__str__(self) -> str
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • 引数なし
戻り値

str

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.cookie import Cookie

obj = Cookie(...)
result = obj.__str__()
print(result)
set

分類: public method

シグネチャ
set(self, key: str, value: str | int) -> None
使い方と仕様

Add or update an attribute of the cookie.

引数
  • key / kind=positional-or-keyword / type=str / 必須 / default=なし
  • value / kind=positional-or-keyword / type=str | int / 必須 / default=なし
戻り値

None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.cookie import Cookie

obj = Cookie(...)
result = obj.set(key="sample", value="sample")
print(result)
to_header

分類: public method

シグネチャ
to_header(self) -> str
使い方と仕様

Return the cookie string for Set-Cookie header.

引数
  • 引数なし
戻り値

str

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.cookie import Cookie

obj = Cookie(...)
result = obj.to_header()
print(result)
response

分類: public method

シグネチャ
response(self, body: str | bytes = 'OK') -> Response
使い方と仕様

Generate a Response object with this cookie set.

引数
  • body / kind=positional-or-keyword / type=str | bytes / 任意 / default='OK'
戻り値

Response

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.cookie import Cookie

obj = Cookie(...)
result = obj.response(body='OK')
print(result)

RequestCookies

分類: public class

Container for cookies parsed from a request.

RequestCookies の全メソッド

__init__

分類: special method

シグネチャ
__init__(self, **kwargs: str) -> None
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • kwargs / kind=variadic-keyword(**kwargs) / type=str / 必須 / default=なし
戻り値

None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.cookie import RequestCookies

obj = RequestCookies()
get

分類: public method

シグネチャ
get(self, key: str, default: str | None = None) -> str | None
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • key / kind=positional-or-keyword / type=str / 必須 / default=なし
  • default / kind=positional-or-keyword / type=str | None / 任意 / default=None
戻り値

str | None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.cookie import RequestCookies

obj = RequestCookies(...)
result = obj.get(key="sample", default=None)
print(result)

ソース情報

  • module: nexom.app.cookie
  • source file: services/venv/lib/python3.10/site-packages/nexom/app/cookie.py
  • generated date: 2026-03-14