On my previous design I blocked access to pages so I used to check for the login, if not logged in use the PHP header function to redirect to "login.php?referred=pictures.php"
The login.php script would then accept the username/password, test them against the UBB member files and if correct, set the UBB cookies and then use the $referred value to redirect the user back to the page they came from. The login.php script still has code in to set the "Ell" cookie but this was used by the Who's Online Hack I had on v6.05. You don't need to set this cookie for v6.3.
With the site redesign I chose not to block pages, just particular features so there is now code in the pages that presents an invitation to login if the cookie isn't present. This popups the login.php page, if all is correct it sets the cookie and reloads the opening page. All the login stages are reported into an access log. It was useful for debugging but it still runs today but it means I can see how many people login outside the forums.
Here's
login.zip which contains login.php and common.php that it includes which has got a few site-wide variables and functions defined in it. Login.php is identical to the one on the site, common.php is just a cut down version.