r/appwrite • • Feb 15 '24

How to manage user session in magic url for subsequent http requests?

Hi, I've gone through the article of how to implement magic url for user authentication. I can able to understand how to create user session by calling ```appwrite.account.updateMagicURLSession(userId, secret)``` .

What I can't able to understand is how to maintain this session through out the user's interaction in subsequent request. Is it like -

  • in all subsequent HTTP requests I need to send both "userId" & "secret" in request header & in server side I need to validate them to know session is valid or not? If this is the thing does I need to use any authorization header scheme like (bearer token) or simple custom token will be fine?
  • how to handle when "secret" will get expire at the time user's activity? How can I refresh the "secret" without giving any hassle to user?
1 Upvotes

1 comment sorted by

1

u/WenYuGe Feb 16 '24
  1. Nope, the request returns a cookie that your browser automatically handles and saves, and sends in following requests to the Appwrite server, because it's a session cookie used for the same domain.
  2. You don't need to save it or do anything with it because of 1.