Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hello everyone.
I just need to see the registered users who are online. And it is important that i need to see only registered one who log in the site using their user name and pass. Since i have never done such a thing before, i have no idea how to handle this. Could someone please help me?
 
or

Some one who logged in can see who who is currently online/active which is valid for 30 mins. from user angle.
 
Thanx in advance.
Posted 8-Nov-12 20:05pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Use a table for storing login details. Insert a record after successful login, log out time is null. After logout update the table with logout time.
You can get the current login user details from this table.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

u can use a table "OnlineUsers" to store data of users currently online.
 
Whenever a user logs in, insert his/her data in this table. In Session_End event in Global.asax file, write a code to remove row of current user.
 
When a session expires of timeout, it will fire "Session_End" event. When the user logs out, end session programmatically, so this event will be fired.
 
In this way, u can keep track of currently online users through "OnlineUsers" table.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

1. In this page, set a variable LastVisitTime to store the last time the user visiting this page.
 
2. Use AJAX Timer, and every interval you can update database about the LastVisitTime of this user.
 
    protected void Timer1_Tick(object sender, EventArgs e)
    {
      sql.update(update membertable set lastvisittime='" +DateTime.Now+ "' where username='" +User.Name+ "'");
 
    }
3. Set the variable offVisitTime to check if this user is visiting the page.
 
DateTime lastvisit = Convert.ToDateTime(sql.select("select lastvisittime from membertable where username='" +User.Name+ "'"));
TimeSpan   tSpanDifferent   =DateTime.Now-lastvisit;
If(tSpanDifferent>SpanSpace)//SpanSpace is the variable which is the time span to chech if the user is off-visiting. And you can set it.
//The user is not visiting this page

 
For example, you can set Timer Interval as 2 minutes and set SpanSpace as 5 minutes.
 
4. After that, you can get the number of visiting users and who is visiting the page via looping.
 
[edit] code tags added [/edit]
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid