333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
 * The namespace's name is the same as the exported EggCookies,
 * so you can solely use CookieGetOptions and CookieSetOptions
 * when you use
 * `import {CookieGetOptions, CookieSetOptions} from 'egg-cookies'`.
 */
declare namespace EggCookies {
  interface CookieGetOptions {
    /**
     * Whether to sign or not (The default value is true).
     */
    signed?: boolean;
    /**
     * Encrypt the cookie's value or not (The default value is false).
     */
    encrypt?: boolean;
  }
 
  interface CookieSetOptions {
    /**
     * The path for the cookie to be set in
     */
    path?: string;
    /**
     * The domain for the cookie
     */
    domain?: string;
    /**
     * Is overridable
     */
    overwrite?: boolean;
    /**
     * Is the same site
     */
    sameSite?: boolean;
    /**
     * Encrypt the cookie's value or not
     */
    encrypt?: boolean;
    /**
     * Max age for browsers
     */
    maxAge?: number;
    /**
     * Expire time
     */
    expires?: Date;
    /**
    * Is for http only
    */
    httpOnly?: boolean;
    /**
    * Encrypt the cookie's value or not
    */
    secure?: boolean;
    /**
     * Is it signed or not.
     */
    signed?: boolean;
  }
}
 
declare class EggCookies {
 
  constructor(ctx?: any, keys?: any);
 
  /**
   * Get the Egg's cookies by name with optional options.
   * @param name The Egg's cookie's unique name.
   * @param opts Optional. The options for cookie's getting.
   * @returns The cookie's value according to the specific name.
   */
  get(name: string, opts?: EggCookies.CookieGetOptions): string;
 
  /**
   * Set the Egg's cookies by name with optional options.
   * @param name The Egg cookie's unique name.
   * @param value Optional. The Egg cookie's real value.
   * @param opts Optional. The options for cookie's setting.
   * @returns The current 'EggCookie' instance.
   */
  set(name: string, value?: string, opts?: EggCookies.CookieSetOptions): this;
}
 
export = EggCookies;