setCookie

Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.cookie

Set a cookie

Params

  1. name*-String

    The name of the cookie to set

  2. value*-Any

    The cookie value to set

  3. settings{}Partial<ISetCookieSettings>

    Some settings to configure your cookie

Example

import { setCookie } from '@blackbyte/sugar/cookie';
setCookie('myCookie', 'hello world');

Settings

  1. path/String

    The path of the cookie to store

  2. domain-String

    The domain on which to store the cookie

  3. expires-String

    The date when the cookie expires. If null, mean never expires

  4. max-age-Number

    The number of seconds until the cookie expires

  5. secure-Boolean

    Specify if the cookie is available only on HTTPS or not. true if page loaded on https, false if not

  6. samesite-Boolean|‘strict’|‘lax’

    Controls whether or not a cookie is sent with cross-site requests, providing some protection against cross-site request forgery attacks (CSRF)

  7. httpOnly-Boolean

    Forbids JavaScript from accessing the cookie, for example, through the Document.cookie property.

Todo

  • testsnormal