dongying2112 2019-02-13 10:08
浏览 132
已采纳

Cookie不会在同一域的不同页面之间持久存在

in part of my code i save a cookie like this

if encoded, err := s.Encode(USER_ID_COOKIE_NAME, value); err == nil {
            user_id := &http.Cookie{
                Name:  USER_ID_COOKIE_NAME,
                Value: encoded,
                Path:  "/",
                HttpOnly: true,
            }
            http.SetCookie(w, user_id)
        }0

when i do, it saves a cookie but when i try to go to another path, the cookie isnt there.

for example: once logged in, im at path "/oauth/square", when i then click on a link to "/settings" my cookie is gone. I can confirm the cookie is set while at the initial path. I've included an image of the cookie in my browser as well. How can i set the cookie so it persists anywhere while on that domain?

screenshot of cookie from browser

  • 写回答

1条回答 默认 最新

  • dovt85093 2019-02-13 10:19
    关注

    the solution was to set the Domain. once i did that everything worked as expected.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测