Comments (1)
Domain 标识定义了Cookie的作用域,指定了哪些主机可以接受Cookie:Cookie应该发送给哪些URL。
无法跨域Cookie设置
我们將Cookie发送给github.com this.$cookies.set('key',value,expire,null,'github.com')
,那么github.com站点下就会出现指定cookie。
我们把这种设置除当前域名或者其父域名之外的其他domain,叫做: 跨域Cookie设置。
现代浏览器出于安全性的考虑,防止不同网站之间进行跨域攻击
,禁止了跨域Cookie设置
,除此之外还无法进行域名向上传递设置
无法进行向上传递设置
当前域名: example.com
一级域名只能设置domain为一级域名,不能设置为二级域名或者三级域名等等,否则cookie无法生成。
this.$cookies.set('key',value,expire,null,'sub.example.com') // invalid/无效的
this.$cookies.set('key',value,expire,null,'sub.sub.example.com') // invalid/无效的
如何使用Cookie中的domain
- 不指定或设置为当前域名
如果不指定,默认为当前主机(不包含子域名。部分浏览器不指定子域名也会存在)。如果指定了Domain,则一般包含子域名。 - 向下传递
sub.sub.example.com
设置this.$cookies.set('key',value,expire,null,'sub.example.com')
或this.$cookies.set('key',value,expire,null,'example.com')
是有效的
from vue-cookies.
Related Issues (20)
- Firefox Loads Expires not as 365 but as session
- Setting cookie of other user/pc
- Additional maintainers? HOT 1
- Removing cookie doesn't work HOT 4
- It doesnt work with firefox and opera except chrome HOT 1
- Property 'get' does not exist on type HOT 3
- ESLint doesn't find this.$cookies HOT 2
- Can't set domain by vue-cookies HOT 2
- Expiry not Working. HOT 1
- Cannot find name '$cookies'
- Expires config example on readme is not correct HOT 1
- support vue3? HOT 7
- httpOnly? HOT 2
- Inject() can only be used inside setup() or functional components HOT 1
- My laravel api login token replacing `|` to `%`
- es not created vue2
- Vue 3 returns this warning in development
- Accept store multidimensional arrays
- vue-cookies isn't working in composition api ? HOT 2
- TS2532: Object is possibly 'undefined' with TypeScript
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-cookies.