Change Button on Nav Bar Dynamically

I have used Login session on my App.

My need is that, before the user logs in the right side of Nav bar should contain login button. Once he logs in that should be a logout button,

How to achive this.

See this answer :