Hi there. Is it possible to have multiple supertok...
# support-questions-legacy
k
Hi there. Is it possible to have multiple supertokens cores for one application? I'm trying to create one core for standard authorization with a small token validity period and one core for a mobile app, where the token will be valid for a long time. At a time I'm calling init ( from supertokens_python) when initialising my Django project . if I call init a second time with configs related to another supertokens core , will it work? I'm using Django btw
r
Hey @kuzyaross. This is not possible yet - the second init will be ignored.
Our sessions are based on inactivity time. So changing the access token lifetime doesn’t really matter if you want to change the session lifetime on a per client basis
You may want to override the refresh function in the session recipe to check how much time has passed since the last refresh, based on client type and if it’s more than a certain amount (for that client type), you can revoke the session and return a 401
k
Oh, i see. So should I override
async def refresh_session(recipe_implementation: RecipeImplementation, refresh_token: str, anti_csrf_token: Union[str, None], contains_custom_header: bool)
from
recipe.session.session_functions
or
async def refresh_session(self, request: BaseRequest, user_context: Dict[str, Any]) ‑> SessionContainer
from
supertokens_python.recipe.session.recipe_implementation
r
yup
in that, fist call the original implementation to get back the session object, then do what i mentioned in my previous comment
k
great, but how i get time when last refresh happened ? should i save this in my DB?
r
You can save this in the session data. So when the session is created, save this value, and when the session is refreshed, update this value in the session data object.
But you can also store in your own db where the key is sessionHandle
k
thanks a lot!!! appreciate it
2 Views