If you know any thing about session events try to implement it.
Otherwise a simple approach would be to keep the userid in hidden field . When Clicked on Login keep that value in hidden field. When clicked on logout ,remove the value from hidden field.
Although try to Implement It The session
.This Hidden field concept is not upto the mark.