Skip to content

interface ICookieManager

cangjie
public interface ICookieManager

功能:定义认证 Cookie 的读写管理能力。

成员概览

成员功能
func getRequestCookie(HttpContext, String)从请求中读取指定 Cookie 值。
func appendResponseCookie(HttpContext, String, ?String, CookieOptions)向响应写入指定 Cookie 值。
func deleteCookie(HttpContext, String, CookieOptions)从响应中删除指定 Cookie。

func getRequestCookie(HttpContext, String)

cangjie
func getRequestCookie(context: HttpContext, key: String): ?String

功能:从请求中读取指定 Cookie 值。

参数:

  • context: HttpContext - 当前 HTTP 上下文。
  • key: String - Cookie 名称。

返回值:

  • ?String - Cookie 值;不存在时返回 None。

func appendResponseCookie(HttpContext, String, ?String, CookieOptions)

cangjie
func appendResponseCookie(context: HttpContext, key: String, value: ?String, options: CookieOptions): Unit

功能:向响应写入指定 Cookie 值。

参数:

  • context: HttpContext - 当前 HTTP 上下文。
  • key: String - Cookie 名称。
  • value: ?String - Cookie 值。
  • options: CookieOptions - Cookie 选项。

返回值:

  • Unit

func deleteCookie(HttpContext, String, CookieOptions)

cangjie
func deleteCookie(context: HttpContext, key: String, options: CookieOptions): Unit

功能:从响应中删除指定 Cookie。

参数:

返回值:

  • Unit