emmett-framework / emmett

The web framework for inventors
Other
1.04k stars 70 forks source link

Clearing sessions from a Post request #290

Closed ianshk closed 3 years ago

ianshk commented 3 years ago

I wondered how it is possible to clear (pop) the sessions from a Post requests.

I have a situation where a post request comes in from a webhook and I need to clear a token which is stored in the session. I don't seem to have access to the session from a Post request though.

I tried just expiring the emmett cookie using Expires = 0 with simplecookie but it seems the cookie can't be cleared in anyway.

gi0baro commented 3 years ago

I think the issue here is not the POST request, but the fact an incoming webhook doesn't not contain any cookie, as its not made by a user.

Probably the best way is to store the token somewhere else (database, redis, etc.) and load it with a Pipe on the standard user request flow. Then you can just drop it with the webhook from the storage.

ianshk commented 3 years ago

I will try that, thanks gi0baro