【问题标题】:How to use cookies in python with other platform如何在 python 中使用 cookie 与其他平台
【发布时间】:2015-08-26 13:46:08
【问题描述】:

我的 python 应用允许人们在第三方平台上上传文件。

他们需要向我的服务器索取令牌以供平台验证

看起来像:

当人们上传他们发布到平台的文件时

<form method="post" action="http://upload.qiniu.com/"
 enctype="multipart/form-data">
  <input name="key" type="hidden" value="<resource_key>">
  <input name="x:<custom_name>" type="hidden" value="<custom_value>">
  <input name="token" type="hidden" value="<upload_token>">
  <input name="file" type="file" />
  <input name="crc32" type="hidden" />
  <input name="accept" type="hidden" />
</form>

我想知道是否可以在每次有人尝试上传文件时询问令牌,或者只是让人们在登录时获取令牌,将令牌设置到 cookie 并使其生命周期与 cookie 一样长? 谢谢。

【问题讨论】:

    标签: python cookies


    【解决方案1】:

    通常的做法是将客户端访问令牌存储为返回用户的 cookie。

    Thisthis 所以帖子也支持这个想法。

    【讨论】:

    • 另一种方式是每次有人尝试上传文件时,使用ajax从服务器获取令牌。哪种方式更好?谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-31
    • 1970-01-01
    • 2011-12-25
    • 2011-05-18
    • 1970-01-01
    相关资源
    最近更新 更多