title: C# WPF login/logout (sessions) - Best practices
body: <p>I need to implement login/logout on my <code>WPF</code> app. Because I was asked to keep track if user is logged in or logged out in time.</p>
  
  <p>I was thinking to implement Session table in DB to keep track of each session (<code>session_start</code> and <code>session_end</code>). That's not problem when user click login and logout. But what if they turn of PC before logout. How I will know when is that worker ended that session (Working time on app). </p>
  
  <p>What is best practice to keep track of session time. </p>
  
  <p>I see problem when I will have sessions without end because PC is turned off (accidentally) and when they turn on PC new session will start from that time and last one will not continue. Maybe store session local to PC and on when I have logout event I will then write in base <code>session_end</code>? </p>
  
  <p>Any practices how best to manage this problem?</p>