123456789101112131415161718192021222324 |
- import Cookie from 'js-cookie'
- export default {
- //获取服务端cookie
- getcookiesInServer: function (req) {
- console.log('get server cookie')
- let service_cookie = {}
- req &&
- req.headers.cookie &&
- req.headers.cookie.split(';').forEach(function (val) {
- let parts = val.split('=')
- service_cookie[parts[0].trim()] = (parts[1] || '').trim()
- })
- return service_cookie
- },
- //获取客户端cookie
- getcookiesInClient: function (key) {
- if (Cookies.get('can-use-cookie')) {
- return Cookie.get(key) || ''
- } else {
- return ''
- }
- },
- }
|