How to server wordpress from SSL and non-SSL URLs

I’m using a plugin for this called WordPress HTTPS. If you still intend to code a solution yourself, maybe you can get some ideas from it at least.