# 1 09.引入cookie存储用户token

> https://vueuse.org/integrations/useCookies/#usecookies
>
> [@vueuse/integrations | VueUse](https://vueuse.org/integrations/README.html)

* #### 安装

```js
npm i universal-cookie
npm i @vueuse/integrations
```

* #### 示例

```js

import { useCookies } from '@vueuse/integrations/useCookies'
const cookie = useCookies()

function set(){
    cookie.set('token','0000')
}

function get(){
    cookie.set('token')
}

function remove(){
    cookie.remove('token')
}
```

*   #### 存储 Token 令牌和用户信息

    > 接上篇,得到用户令牌，并保存到cookie当中
    >
    > login.vue

```js
import { useCookies } from '@vueuse/integrations/useCookies'

const cookie = useCookies()


...略
            // 存储 token 和用户相关信息
            cookie.set('admin-token', res.data.data.token)

            // 跳转到后台
            router.push('/')
```
