egg/docs/app_dev/plugins/cookie.md
2016-07-17 12:48:09 +08:00

18 lines
491 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

cookie
=====
## API
* ctx.getCookie(name, opts)
* ctx.setCookie(name, val, opts)
* ctx.deleteCookie(name)
## cookie options
对于 cookie 的使用注意点:
* 对于前端需要可见的数据,有两种情况
* 前端可以修改 signed: false, encrypt: false, httpOnly: false
* 前端只能读,不允许写 signed: true, encrypt: false, httpOnly: false
* 对于只是后端用的数据,使用 cookie 作为 store那么设置 encrypt: true, signed: false, httpOnly:true