https://github.com/battlefieldduck/vue-cli-plugin-cookie
🍪 Vue CLI 3/4 Plugin for handling browser cookies
https://github.com/battlefieldduck/vue-cli-plugin-cookie
cli cookie cookies vue vue-cli-4 vue-cli-plugin vue-cli4 vue-cookie vue-cookies vue3
Last synced: about 1 month ago
JSON representation
🍪 Vue CLI 3/4 Plugin for handling browser cookies
- Host: GitHub
- URL: https://github.com/battlefieldduck/vue-cli-plugin-cookie
- Owner: BattlefieldDuck
- License: mit
- Created: 2020-08-22T18:12:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-23T00:06:32.000Z (over 4 years ago)
- Last Synced: 2025-02-14T01:43:30.946Z (3 months ago)
- Topics: cli, cookie, cookies, vue, vue-cli-4, vue-cli-plugin, vue-cli4, vue-cookie, vue-cookies, vue3
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/vue-cli-plugin-cookie
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vue-cli-plugin-cookie
🍪 Vue CLI 3/4 Plugin for handling browser cookies### Install
add the cookie plugin with vue-cli or vue-cli UI. `import` and `.use()` will be added to main.js automatically
```sh
vue add cookie
```### Example Usage
##### Get a cookie
```js
this.$cookie.get('jwt_token')
```##### Set a cookie
```js
this.$cookie.set('jwt_token', 'cookie_data')
this.$cookie.set('jwt_token', 'cookie_data', { sameSite: 'Lax', expires: '1Y' }) // set SameSite to Lax, Expires to 1 year
this.$cookie.set('jwt_token', 'One year', { expires: '1Y' })
this.$cookie.set('jwt_token', 'One month', { expires: '1M' })
this.$cookie.set('jwt_token', 'One day', { expires: '1D' })
this.$cookie.set('jwt_token', 'One hour', { expires: '1h' })
this.$cookie.set('jwt_token', 'One minutes', { expires: '1m' })
this.$cookie.set('jwt_token', 'One seconds', { expires: '1s' })
```##### Remove a cookie on the current domain
```js
this.$cookie.remove('jwt_token')
this.$cookie.delete('jwt_token') // alias of remove
this.$cookie.remove('jwt_token', { domain: 'parentdomain.com' }) // remove the parent domain's cookie
```##### Get all cookies
```js
this.$cookie.getAll()
```