У меня проблемы с получением куки
Весна
Spring boot отправляет несколько файлов cookie, используя ниже
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SampleController {
@PostMapping("/test")
public Object test(HttpSession session, HttpServletResponse response) {
String cookie1 = "first";
String cookie2 = "second";
Cookie firstCookie = new Cookie("uid", cookie1);
firstCookie.setPath("/");
firstCookie.setMaxAge(60 * 60 * 24 * 30);
Cookie secondCookie = new Cookie("token", cookie2);
secondCookie.setPath("/");
secondCookie.setMaxAge(60 * 60 * 24 * 30);
response.addCookie(firstCookie);
response.addCookie(secondCookie);
}
}
ReactNative
Отправка ответа с двумя куки,
и ниже реагируем на нативный пример кода, чтобы перехватить cookie
function test() {
fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
credentials: 'include',
'Content-Type': 'application/json',
}
}).then((response) => {
for (const [name, value] of response.headers) {
if (name === "set-cookie") {
console.log(value)
}
}
});
}
Я проверил куки с response.header, но у меня последний добавленный (второй - cookie2)
Реагировать на результат отладки
и я попробовал также python, почтальон, я вижу, что три куки включают jsession
Почтальон Cookie View
как я могу получить два печенья?