search

Home  >  Q&A  >  body text

python - 微信内置浏览器的Cookie为什么存不住?已经设置expire。

我需要在客户端存一个每天0点过期的值,想了想还是cookie最方便,于是选用了cookie。
所以这就是我的接口实现:

@psb.route('/front' + psb_ondebug.flag + '/api/todaylimit')
def gettodaylimit():
    limit = random_pick([16, 25, 50, 61, 75, 100, 160, 610],[0.06, 0.06, 0.08, 0.26, 0.12, 0.24, 0.17, 0.01])
    tomorrow = datetime.date.today() + datetime.timedelta(days=1)
    resp = make_response(str(limit),200)
    resp.set_cookie('limit',str(limit),expires=time.mktime(tomorrow.timetuple()))
    return resp

这个接口的用途是获取这个每天零点过期的limit值并设置cookie,在其他的接口里用这个cookie。
但是在实际测试中,普通浏览器没有任何问题,微信浏览器每次只要刷新就会丢失cookie,请问这是为什么?如何解决?

巴扎黑巴扎黑2889 days ago577

reply all(2)I'll reply

  • 黄舟

    黄舟2017-04-17 17:52:32

    Of course the form is gone after the cookie is destroyed. WeChat is not a browser. It just doesn’t use the system’s webview component and just made it by itself. And this is only true for the Android version. iOS is still the system’s uiwebview.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 17:52:32

    I heard that not all accounts are like this, and some paid accounts seem to have no problem with cookies.

    reply
    0
  • Cancelreply