A lot of refactoring and editing later...
Implemented most of the required functionalities. Need to add tracking of recently visited page for redirect after login
redirection after logging in, signing up, and logging out works fine
fixed some issues with cookies and redirection caused by random regenerating the secret every time
last redirect-after-changing-login-status-bug fixed