The whole logic behind the code is when user visits
domain.tld/page_that_requires_login.php
he gets redirected to domain.tld/login.php?forward=page_that_requires_login.php
domain.tld/page_that_requires_login.php
he gets redirected to domain.tld/login.php?forward=page_that_requires_login.php