未在浏览器中设置Cookie [英] Cookie is not set in browser

查看:61
本文介绍了未在浏览器中设置Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将JAX-RS Web服务与AngularJS前端连接。如您在所附的屏幕截图中所见,Chrome可以读取和解析Set-Cookie值,但由于未知原因而将其关闭。

I have been trying to connect the JAX-RS web service with AngularJS frontend. As you can see at the attached screenshots, the Chrome can read and parse the Set-Cookie value, but dismisses it for unknown reason.

JAX-RS代码段:

JAX-RS snippet:

c1 = new NewCookie("session_id", uuid, "/", null, null, COOKIE_MAX_AGE, false);

return Response.status(200).cookie(c1).build();

屏幕截图:

推荐答案

令人惊讶的是,这是由错误请求引起的。我没有在AngularJS $ http.post请求中设置 withCredentials:true字段。

Surprisingly, it was caused by the bad request. I did't set the " withCredentials: true" field in my AngularJS $http.post request.

https://stackoverflow.com/a/8530284/1349442

这篇关于未在浏览器中设置Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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