Listing 9.17: code to implement friendly forwarding in sessions_helper
up until 9.3: added redirect for bad login