alfresco-ng2-components/docs/core/cookie.service.md
Andy Stark e03f3a1a6b [ADF-3323] Fixed broken links in doc files (#3662)
* [ADF-3323] Fixed URL path to Typescript source files

* [ADF-3323] Fixed and checked broken links caused by previous bug
2018-08-14 15:42:45 +01:00

1.4 KiB

Added, Status, Last reviewed
Added Status Last reviewed
v2.0.0 Active 2018-03-29

Cookie service

Stores key-value data items as browser cookies.

Class members

Methods

  • clear()

  • getItem(key: string): string|null
    Retrieves a cookie by its key.

    • key: string - Key to identify the cookie
    • Returns string|null - The cookie data or null if it is not found
  • isEnabled(): boolean
    Checks if cookies are enabled.

    • Returns boolean - True if enabled, false otherwise
  • setItem(key: string, data: string, expiration: Date|null, path: string|null)
    Sets a cookie.

    • key: string - Key to identify the cookie
    • data: string - Data value to set for the cookie
    • expiration: Date|null - Expiration date of the data
    • path: string|null - "Pathname" to store the cookie

Details

This service uses browser cookies to store data in the form of key-value pairs. An optional expiration date can be supplied for the cookie and a path can be used to reduce the chances of name clashes with cookies from other sources.

Cookies have a storage size limit that varies between browsers but is often around 4KB. Consider using web storage if you need to store data beyond this size.

See also