Zend certified PHP/Magento developer

How do I insert a sign in link into a CMS block and have it redirect back to page of origin after user logged in

I have a global banner that includes a CMS block on every page. In this block, I have a link to login and to register. I tried just setting the path to the login page, but i quickly realized that it was not including the /referred and the rest of the information important to tell magento how to redirect the user after log in. Currently it takes them to “My Account” page after login in through this method. How would I generate that string to put in the href pragmatically inside of a CMS block?