In the spirit of perl, there are dozens of ways to do it, but the most appropriate depends on the rest of your design.
This question has been answered quite a few times
here --
Jay "Yohimbe" Thorne, alpha geek for UserFriendly
Please use the linking conventions. When you give a full
URL, if someone follows your link but is using this site
under a different name, they will lose their login.
That is instead of constructing the above link with either
of:
And a tip for those who don't want to accidentally post as
Anonymous Monk. Set your personal theme to anything
other than the site default. Then when you follow
a link that can leave you logged out, you will see
everything change colour and know what happened...