Notify user about session expiration via LiveView modal without losing context?

Case: User keeps an open page for too long. Session expires. User clicks a link or submits a form and get redirected to login page. (Actually the default Phoenix settings lead to exception Plug.CSRFProtection.InvalidCSRFTokenError, if user submits a form after his/her session expired, which is not user friendly at all.)

A more user friendly experience is to display a pop-up “your session expired, please re-login”. Ideally with login form in the same pop-up keeping the user on the same page and refreshing CRFT tokens in forms, so user could continue without losing context.

Is there any tutorial or code sample on how to achieve this using LiveView? I hope it is already solved somewhere, the case is pretty obvious. Thanks