MCPcopy
hub / github.com/growthbook/growthbook / setValue

Method setValue

packages/back-end/src/util/cookie.ts:14–44  ·  view source on GitHub ↗
(value: string, req: Request, res: Response, maxAge: number = 0)

Source from the content-addressed store, hash-verified

12 }
13
14 setValue(value: string, req: Request, res: Response, maxAge: number = 0) {
15 const opts: {
16 httpOnly: boolean;
17 maxAge: number;
18 secure: boolean;
19 path?: string;
20 } = {
21 httpOnly: true,
22 maxAge: maxAge || this.expires,
23 secure: req.secure,
24 };
25 if (this.path) {
26 opts.path = this.path;
27 }
28
29 if (!value) {
30 res.clearCookie(this.key, opts);
31 } else {
32 res.cookie(this.key, value, opts);
33 }
34
35 // Clear any legacy cookie at the default path during transition
36 if (this.path) {
37 res.clearCookie(this.key, {
38 httpOnly: true,
39 secure: req.secure,
40 });
41 }
42
43 req.cookies[this.key] = value;
44 }
45
46 getValue(req: Request) {
47 return req.cookies[this.key] || "";

Callers 15

postRefreshFunction · 0.80
postOAuthCallbackFunction · 0.80
setResponseCookiesFunction · 0.80
wFunction · 0.80
processCallbackMethod · 0.80
getRedirectURIMethod · 0.80
getConnectionFromRequestFunction · 0.80
deleteAuthCookiesFunction · 0.80
setIdTokenCookieFunction · 0.80
postVercelIntegrationSSOFunction · 0.80
SQLInputFieldFunction · 0.80

Calls 1

cookieMethod · 0.80

Tested by

no test coverage detected