Recalling location in site after login

Being a student, i’m learning all these new PHP, MySQL tricks and one that I’m wanting to integrate into one of my final projects has to do with saving the current location of a user in the site if they are prompted to login.

Basically, I’m creating a blog that only displays a few lines of each entry and has an option to “view full entry” and or “comment”. If a user isn’t logged in, how can i first, detect thier loggin status if they click on either of the links in the blog. Second, save their location in the site while they login and authentication is being approved. Third, return them to either their previous location or to the new requested page they intitially clicked the link for?

Might sound confusing, but if your reading this and you know what your doing, it makes perfect sense. Thanks for any and all help. I can’t wait until i’m browsing this site and helping people with questions like this!!