test.domain.com我希望設定從設定的cookie,.domain.com以便它仍然可以從anothertest.domain.com. 基本上 cookie 應該在子域之間共享。
我呼叫了部署在 test.domain.com 的后端,并設定了帶有 OK 回應的 cookie,如下所示:
Ok("some response").withCookies(Cookie("id", id), Cookie("token", token))
在 application.conf 中,我將會話域設定為“.domain.com”-
session {
\#Sets the cookie to be sent only over HTTPS.
\#secure = true
\#Sets the cookie to be accessed only by the server.
\#httpOnly = true
\#Sets the max-age field of the cookie to 5 minutes.
\#NOTE: this only sets when the browser will discard the cookie. Play will consider any
\#cookie value with a valid signature to be a valid session forever. To implement a server side session timeout,
\#you need to put a timestamp in the session and check it at regular intervals to possibly expire it.
\#maxAge = 300
\#Sets the domain on the session cookie.
domain = ".domain.com"
}
但是,cookie 被設定為test.domain.com而不是.domain.com. 我想將此 cookie 與anothertest.domain.com.
你能幫我解決這個問題嗎?
uj5u.com熱心網友回復:
您不必更改配置,您可以在創建 cookie 時添加它的所有屬性。
Cookie("bla", bla).withDomain(xxx)
// Or
Cookie("bla", bla, domain = XXX)
(不確定確切的名字,我現在沒有檔案)
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/532054.html
