GithubHelp home page GithubHelp logo

set domain about vue-cookies HOT 1 CLOSED

cmp-cc avatar cmp-cc commented on May 30, 2024
set domain

from vue-cookies.

Comments (1)

cmp-cc avatar cmp-cc commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.