search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
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

Web ProgrammingArticlesForumsFAQs
JavaScript
ASP
ASP.NET
Web Services

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

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Operating SystemsArticlesForumsFAQs
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
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 
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


 
try this!
sundar k replied to Paddy Mac at 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

 
  count the number of current users / sessions
K Pravin Kumar Reddy replied to Paddy Mac at 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

 
There is nothing "stored" in your application
Peter Bromberg replied to Paddy Mac at 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".

 

 
Thanks guys
Paddy Mac replied to Peter Bromberg at Wednesday, November 29, 2006 4:19 AM
cheers for the info guys!