You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Value string`json:"value"`// The value of the cookie
380
+
Path string`json:"path"`// Specifies a URL path which is allowed to receive the cookie
381
+
Domain string`json:"domain"`// Specifies the domain which is allowed to receive the cookie
382
+
MaxAge int`json:"max_age"`// The maximum age (in seconds) of the cookie
383
+
Expires time.Time`json:"expires"`// The expiration date of the cookie
384
+
Secure bool`json:"secure"`// Indicates that the cookie should only be transmitted over a secure HTTPS connection
385
+
HTTPOnly bool`json:"http_only"`// Indicates that the cookie is accessible only through the HTTP protocol
386
+
SameSite string`json:"same_site"`// Controls whether or not a cookie is sent with cross-site requests
387
+
Partitioned bool`json:"partitioned"`// Indicates if the cookie is stored in a partitioned cookie jar
388
+
SessionOnly bool`json:"session_only"`// Indicates if the cookie is a session-only cookie
389
389
}
390
390
```
391
391
392
-
:::info
393
-
394
-
Partitioned cookies allow to partition cookie jar by top-level site. You can check out [CHIPS](https://developers.google.com/privacy-sandbox/3pcd/chips) for more information.
Partitioned cookies allow to partition the cookie jar by top-level site, enhancing user privacy by preventing cookies from being shared across different sites. This feature is particularly useful in scenarios where a user interacts with embedded third-party services that should not have access to the main site's cookies. You can check out [CHIPS](https://developers.google.com/privacy-sandbox/3pcd/chips) for more information.
409
+
410
+
:::
411
+
412
+
```go title="Example"
413
+
app.Get("/", func(c fiber.Ctx) error {
414
+
// Create a new partitioned cookie
415
+
cookie:=new(fiber.Cookie)
416
+
cookie.Name = "user_session"
417
+
cookie.Value = "abc123"
418
+
cookie.Partitioned = true// This cookie will be stored in a separate jar when it's embeded into another website
419
+
420
+
// Set the cookie in the response
421
+
c.Cookie(cookie)
422
+
return c.SendString("Partitioned cookie set")
423
+
})
424
+
```
425
+
412
426
## Cookies
413
427
414
428
Get cookie value by key, you could pass an optional default value that will be returned if the cookie key does not exist.
0 commit comments