I have given up on this. Instead of redirecting the user, I have added a link on the login form which allows users to return to the page in question.
Well, if it works and you’re happy with it, that’s fine. If not, however, don’t give up so quickly!
Thank you for everything.