How to require login to access a page -- and redirect if not logged in

I have a "create" page which lets users create something on the site. I would like to be able to check if the user is logged in when they are sent to this page. If yes then they can access it otherwise they will be redirected to a login page ... after they login they are redirected back to the first page

What is the best way to accomplish this -- I am pretty comfortable with php so I can make the mods just need to know what parts of the api to use