Skip to content

How to create a remember me function for JWTAuth? #547

Answered by frankie567
JoseMoreville asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there!

Background

First of all, rather than a JWT authentication, I think you need a Cookie authentication. It'll be way easier to manage its lifetime then.

Now if you look at how to configure this authentication backend:

cookie_authentication = CookieAuthentication(secret=SECRET, lifetime_seconds=3600)

The property lifetime_seconds is here to specify how long this cookie will be stored in the browser. If you set this value to None*, it'll mean it's a session cookie (https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#define_the_lifetime_of_a_cookie) that will be deleted when the user closes its browser. If you set a value, like 86400, the browser will remember it for 86400 seconds.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@JoseMoreville
Comment options

@frankie567
Comment options

@ziruzavar
Comment options

@frankie567
Comment options

Answer selected by JoseMoreville
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants