此行爲什麼Grails的cookieService.get總是返回null?
def cookieService
def cookieContent = cookieService.get("cookieName")
回報null
,雖然餅乾的設置是否正確。我也嘗試從其他cookie中獲取內容,但它僅返回null
。有人知道我做錯了什麼嗎?
設置Cookie是這樣的:
cookieService.set(response,"cookieName", user.id + "_" + passWordHash, 10 * 365 * 24 * 3600)
response.setCookie("cookieName", user.id + "_" + passWordHash, 10 * 365 * 24 * 3600)
編輯: 我在Firefox中的Cookie設置,我的cookie的路徑是「/登錄」,所有其他的餅乾路徑「/」看見了,我不知道爲什麼,但也許這是問題。有人知道我可以如何改變它的路徑嗎?
你試圖調用這個地方?!控制器? –