Click here to Skip to main content
15,906,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is there any way to count the time from login to logout in c#
also i wants to so the timer in my page from 00:00 when login and upto logout
i need the timer with display in my asp page, don't want to show datetime.now, i need from 00:00 to untill logout
Posted

Hi,
You can keep track of login and logout times of user for that use a best example on code project:
Tracking users login/logout times on your site
 
Share this answer
 
Comments
tssrajkumar@gmail.com 11-Jan-12 5:43am    
thanx, but i need increased counter from login to logout
Use this script on master page
Javascript Timer
 
Share this answer
 
hi,

Using javascript, you can get the logged in datetime.Store it in variable.Call a java script method for some interval..say 1min ,

log time = nowdate_time - logged in datetime.


Like:
<body onload="updateClock(); setInterval('updateClock()', 1000 );">


function updateClock ()
{
  var Loggeddatetime = new Date ();
 
  var LoggedHours = Loggeddatetime.getHours ();
  var LoggedMinutes = Loggeddatetime.getMinutes ();
  var LoggedSeconds = Loggeddatetime.getSeconds (); 

  // Pad the minutes and seconds with leading zeros, if required
  LoggedMinutes = ( LoggedMinutes < 10 ? "0" : "" ) + LoggedMinutes;
  LoggedSeconds = ( LoggedSeconds < 10 ? "0" : "" ) + LoggedSeconds;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( LoggedHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  LoggedHours = ( LoggedHours > 12 ) ? LoggedHours - 12 : LoggedHours;

  // Convert an hours component of "0" to "12"
  LoggedHours = ( LoggedHours == 0 ) ? 12 : LoggedHours;

  // Compose the string for display by calculating the difference 
  //var currentTimeString 

  // Update the time display
  document.getElementById("<%=lblDateTime1.ClientID %>").innerHTML = currentTimeString;
  

}


Hope this helps.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900