最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python 3.x - How to delete a cookie in FastHTML? - Stack Overflow

programmeradmin0浏览0评论

I want to delete a cookie (for instance "cookie1") in the endpoint "/delete_cookie1"

import fasthtml as fh

@app.get("/delete_cookie1")
def delete_cookie1(request):
    my_delete_cookie_function(request,'cookie1') # ?????????

Any help? Thanks

I want to delete a cookie (for instance "cookie1") in the endpoint "/delete_cookie1"

import fasthtml as fh

@app.get("/delete_cookie1")
def delete_cookie1(request):
    my_delete_cookie_function(request,'cookie1') # ?????????

Any help? Thanks

Share Improve this question asked Jan 21 at 10:39 Ximo DanteXimo Dante 12511 bronze badges 1
  • docs.fastht.ml/api/core.html#cookie set max-age to 0 – mr mcwolf Commented Jan 21 at 10:47
Add a comment  | 

1 Answer 1

Reset to default 0

Thanks to the comment from @mr-mcwolf , setting the parameter max_age=0, the cookie "cookie1" can be removed as follows:

from fasthtml import common as fh 
app = fh.FastHTML

@app.get("/removecookie1")
def getdbpools(req):
    return fh.cookie(key='cookie1', value='', max_age=0)
发布评论

评论列表(0)

  1. 暂无评论