Angular:从一个请求中获取cookie并在另一个请求中使用 [英] Angular: get cookie from one request and use in another

查看:1436
本文介绍了Angular:从一个请求中获取cookie并在另一个请求中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Angular应用程序,它可以通过 $ http example.com / ...的远程服务(couchdb)执行一些请求/ myservice 。服务需要auth,通过调用指定地址 example.com/_session 与名称和密码,并返回会话cookie AuthSession 。问题是,当呼叫服务完成时,不使用cookie。也许由于cookie是每会话Http-only(并且不能更改)导致的问题。



我认为解决方案是从auth响应抓取cookie,存储并强制手动进入服务调用。但我不知道如何:


  1. 从$ http回应取得Cookie

  2. with $ http response

有任何建议吗?



UPD:pics

所有Cookie





但仅可用此





Auth Cookie发送到 / _ session 请求,但不发送给其他人



解决方案

没有解决方案,根据到这



现在我认为couchdb是一个问题的根源。
所以,我会尝试找到另一种方法在手动做沙发。


I have simple Angular app, which can perform some requests over $http to remote service (couchdb) at example.com/.../myservice. Service requires auth, which done by calling specified address example.com/_session with name and password and it returns with session cookie AuthSession. Problem is that cookie is not used when calls to service is done. Maybe problem caused because cookie is per-session Http-only (and that's can't be changed).

I think the solution is grabbing cookie from auth response, store and force it into service calls manually. But I don't know how to:

  1. Get cookie from $http response
  2. Force it with $http response

Any suggestions?

UPD: pics

All cookies

but available only this

Auth cookie, which sent to /_session request, but not to others

解决方案

There's no solution, according to this

Now I think that couchdb is a source of problem. So, I'll try to find another ways to do auth in couch manually.

这篇关于Angular:从一个请求中获取cookie并在另一个请求中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆