Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

  View Other Visual Studio .NET Posts   Ask New Question  Ask New Question With Power Editor

can I tell how is currently logged into my web app?
Paddy Mac posted at Monday, November 27, 2006 6:05 AM

Hi,

Is it possible to tell what users are currently logged into my web app? From time-to-time I the web app may need upgrades, so I want to find out if any users are logged in before I upload.

I'm using forms authenication with SQL Server 2000.

Can this be done? and if so how would I do it?

Thanks,

Paddy

Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0
try this!
sundar k replied to Paddy Mac on Monday, November 27, 2006 6:39 AM

I am not sure whether we have any direct method for finding the users who are logged in,

since you have mentioned that using forms authentication, you would have mentioned the list of
users who will be using your application in web.config file, typically your web.config will look like this,

<configuration>
    <system.web>
        <customErrors mode="Off"/>
        <authentication mode="Forms">
            <forms name="appNameAuth" path="/" loginUrl="login.aspx" protection="All" timeout="30">
                <credentials passwordFormat="Clear">
                    <user name="jeff" password="test" />
                    <user name="mike" password="test" />
                </credentials>
            </forms>
        </authentication>
        <authorization>
            <deny users="?" />
        </authorization>
    </system.web>
</configuration>


since you have these user details in place, you maintain this information in a table with a switch saying Current logged in?(yes/no) , whenever a person logins your application, change the database switch to yes and whenever he logsoff update to no, so pick up all 'yes' and u will know who are all logged in!

i found this article about forms authentication , you can also look into this, it doesnt talk about the above db logic, but its good! http://www.15seconds.com/issue/020220.htm

Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0

count the number of current users / sessions
K Pravin Kumar Reddy provided a rated reply to Paddy Mac on Monday, November 27, 2006 6:53 AM

hello

check here

There are a few ways you can approach this. One is to track users using global.asa and an application variable: 
 

<script language=vbScript runat=server> 
 
sub session_onStart() 
 
    application.lock() 
    application("SCount") = application("SCount") + 1 
    application.unlock() 
 
end sub 
 
sub session_onEnd() 
 
    application.lock() 
    application("SCount") = application("SCount") - 1 
    application.unlock() 
 
end sub 
 
sub application_onStart() 
 
    ' don't need a lock in onStart() 
    application("SCount") = 0 
 
end sub 
 
</script>
 
Then, in any page: 
 
<% 
    Response.Write "Current session count: " & _ 
        application("SCount") 
%>

http://classicasp.aspfaq.com/general/how-do-i-count-the-number-of-current-users/sessions.html

Reply    Reply Using Power Editor
K Praveen Kumar Reddy MCTS.
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0

There is nothing "stored" in your application
Peter Bromberg replied to Paddy Mac on Monday, November 27, 2006 12:12 PM

that tells you whether a user is "logged in". When a user requests a page, their Forms Ticket (cookie) is transmitted with the request, and the Application_AuthenticateRequest method is fired.  Aside from using some sort of  "counting code" like Kevin suggested, this is your only other place that you can set up some sort of persistent mechanism (application state) to tell you that a user is , erm, "logged in".

 

Reply    Reply Using Power Editor
Peter Bromberg is a C# MVP, MCP, and .NET expert who has worked in banking, financial and telephony for over 20 years. Pete focuses exclusively on the .NET Platform, and currently develops SOA and other .NET applications for a Fortune 500 clientele. Peter enjoys producing digital photo collage with Maya,playing jazz flute, the beach, and fine wines. You can view Peter's UnBlog and IttyUrl sites.
Please post questions at forums, not via email!
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0

Thanks guys
Paddy Mac replied to Peter Bromberg on Wednesday, November 29, 2006 4:19 AM

cheers for the info guys!
Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0