Hello Suraj,
Thank you for reaching out and I am happy to assist you with this.
There are two ways to achieve this. The first and the best one is to fire. the login process using ajax which will bypass the cache.
Alternatively, you can use Page Fragment Cache and wrap the specific PHP code with replacing the PHP code and excluding the part of the page from being cached.
You can check more details on our FAQ page.
Thanks!