Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

document.cookie获取不到后端发回的cookie

准备做个单点登录,两个项目域名分别是a.xxx.com, b.xxx.com

我把项目上线后,当一个项目登录过后,登录接口会返回cookie
image.png
并且在两个项目域名下也有相应的cookie
image.png
但是我取不到cookie(全局beforeRouteEnter里),无论是Cookie-js,还是document.cookie,

我需要根据access_token来判断是否登录,但无论如何都取不到cookie,这是什么原因呢?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. cookie域名和网页域名是否一致?
  2. cookie是否设置了path
  3. cookie是否设置了http only
  4. 可以看下过期时间是否正常

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...