One thing is that often times you also care about the POST vars that got you to that page, so you need to somehow persist that as well, which is harder since you can't get a redirect to POST easily.
So the problem is (sometimes) harder than it appears.
The sites I've designed just do the login live on the page you needed it on, via AJAX, without actually redirecting you anywhere. Of course, each displayed page has to know both its guest and user state (and be able to transition between them), but that seems like the correct approach, anyway.
So the problem is (sometimes) harder than it appears.