Click here to Skip to main content
16,008,490 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I have an Web Application and number of users are there, at the time of login I am putting the name of user in session. So my problem is that i want to fetch all the user name who has login the application.


Thanks in Adv.
Posted

Hi,

You can store your session information in database. After storing you can get the number of users that are login. But the problem will be with session expiration. if your session will not expire if you close your brower user will be look like online.

Check this article : Store Session in SQL Server[^]

Other way is you can set a flag in userMaster table and once user logout you can reset it. this way you can also get the online user. But again in this scenario you have such issue with closing/browser crash.
 
Share this answer
 
Comments
Jimut123456789 14-Sep-12 2:04am    
Ok can you please help me If I will colse the browser or automatically session will be out then which event will fire.
AmitGajjar 14-Sep-12 2:07am    
Yes, there is workarround but it's expensive, you can set some last access time in the database and when user close the browser this time will not update. Time will update from one of the SP which will be executed along with other process. if browser is closed, user will be mark as set in the flag but last access date will be invalidated as its more then 10 min from current time.

hope i answered your query.
Jimut123456789 14-Sep-12 2:08am    
Thanks.....
AmitGajjar 14-Sep-12 2:10am    
Mark solution as answered if it works for you. :)
Karthik Harve 14-Sep-12 2:34am    
Nicely explained My 5!!!!
Hi,

this article may help you.
How to show number of online users visitors for ASP.NET website[^]

[UPDATED]

To get all user names
check this Thread[^]
 
Share this answer
 
v2
Comments
Jimut123456789 14-Sep-12 1:59am    
Thanks...
But Sir I want to fetch the user name ....
Karthik Harve 14-Sep-12 2:09am    
Check my updated answer
AmitGajjar 14-Sep-12 2:31am    
nice link 5+
Karthik Harve 14-Sep-12 2:33am    
Thanks amit.!
Hi,

This Articale May be Help You ,

Take One Globle.asax page this having events Like This;

C#
void Application_Start(object sender, EventArgs e)
        {
            Application["Toatal"] = 0;
            Application["Online"] = 0;
            Session.Timeout = 60;

        }

        void Application_End(object sender, EventArgs e)
        {
            //  Code that runs on application shutdown

        }

        void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs

        }

        void Session_Start(object sender, EventArgs e)
        {
            Application["Toatal"] = Convert.ToInt32(Application["Toatal"]) + 1;
            Application["Online"] = Convert.ToInt32(Application["Online"]) + 1;

        }

        void Session_End(object sender, EventArgs e)
        {
            Application["Online"] = Convert.ToInt32(Application["Online"]) - 1;

        }



Take another Aspx page In that take two lables

and assign this two vales
VB
Application["Toatal"] and
            Application["Online"]


you can get total number of visiters and online visiters...
 
Share this answer
 

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