in reply to How to get the logged in user id

Not surprisingly merlyn has already written a snippet of code which performs this task - It can be found here on this site.