$cookieProvider
Configuration provider for
$cookie service.Description
Instance of CookieProvider for configuring the $cookie service.
It allows you to set global default options that will apply to all cookies
created, updated, or removed using the $cookie service.
Properties
$cookieProvider.defaults
The defaults property defines global cookie settings. These values are applied to the
$cookie service at initialization, and every cookie created through $cookie.put() or $cookie.putObject() will automatically inherit these defaults,
unless overridden per-cookie.
- Type: CookieOptions
- Default:
{} - Options:
Property Type Description path stringURL path the cookie belongs to. Defaults to the current path. Commonly set to '/'to make cookies accessible across the entire site.domain stringThe domain the cookie is visible to. Useful for subdomains (e.g., .example.com).expires DateExpiration date. If omitted, the cookie becomes a session cookie (deleted on browser close). secure booleanIf true, the cookie is only sent over HTTPS.samesite "Strict" | "Lax" | "None"Controls cross-site cookie behavior. Required when secure: trueand cross-site use is intended.httponly Not supported. Browser JS cannot set HttpOnlycookies. This must be done on the server.
- Example:
angular .module('demo', []) .config([ '$cookieProvider', /** @param {ng.CookieProvider} $cookieProvider */ ($cookieProvider) => { $cookieProvider.defaults = { path: '/', secure: true, samesite: 'Lax' }; } ]);
For service description, see $cookie.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.