Wrox Programmer Forums
|
ASP CDO As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP CDO section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2005, 01:39 AM
Registered User
 
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default same user multiple logins(solved)

hi all,

i am new subscriber to this site.this is my first letter to this group.

my problem is how to restrict the user from login more than one machine at the same time.
for this i have written some code in session_OnEnd which is in global.asa file.it shoulb fire when the session is expired.but it is not working.here i am giving my code which is in global.asa file

<script language="vbscript" runat="server">
    sub Application_OnStart

    end sub

    sub Application_OnEnd
        ''code to remove all user names
        for each x in Application.Contents
            Application.Contents.Remove(x)
        next
    end sub

    sub Session_OnEnd
        ''code to remove the user,whose session is expired
        for each x in Application.Contents
            if Application.Contents(x)= session("user_id")
                 Application.Contents.Remove(x)
            end if
        next
    end sub
</script>

first, i tell what i am doing in login page.
when user logged in to my application i am storing userid in application.contents object after checking whether userid is already exist or not.if not ia m storing user id in application contents.till here this is fine and its working properly.
but the thing is in the above code i am trying to remove the userid
(whose session is expired) from the application.contents list
it is not working, can you help me.
 
Old February 2nd, 2005, 12:01 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

I have written an article regarding this in MSDN .. check it out @ http://www.microsoft.com/india/msdn/articles/161.aspx

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old February 2nd, 2005, 12:03 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

oops I didn't realise this to be the Classic ASP forum ... the link which i have posted above is for ASP.NET

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old February 2nd, 2005, 12:09 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Extract from that article which might interest you:

Quote:
quote:Let us create a Boolean datatype in our database, as part of the User table. I have named it isLogged for sake of clarity. As soon as the login process for a given user account succeeds, the value of this flag would be set to True. Now, let me take a minute in-between to define the success of the login process.

During the login process, as part of verifying the credentials against the User table, we also check for the value of isLogged. If the value is already set to True, it clearly means that the user is already logged on to the system. Aha! Gotcha! We redirect the user to an appropriate page explaining the problem clearly and thus login fails. On the other hand, if the value of isLogged is false, we set it True and allow the user to proceed further with the application.

One of the easier ways to implement this logic is to make use of the global.asax. This file has two routines namely Session_onStart and Session_onEnd. I am sure the names are self-explanatory. So we put the code login process in Session_onStart and set the value of isLogged to False in Session_onEnd. This would be our simple and straightforward logout process.

Ok, now what?! The traditional approach would work perfectly under normal scenarios. i.e. a user logs onto our site, has some good time minding his / her own business and logs out. What will happen if he doesn’t log out and just closes the browser or what if he simply moves on to visit another site without even logging out?!!

One of obvious reasons why we can’t trust Session_onEnd is that there is no guarantee that the event will be triggered when the browser is closed. Does this mean that the whole purpose of Session_onEnd is defeated? May be not. The event will be triggered after the session times out. Normally, this time would be about 20 minutes. So there are chances that our User gets frustrated and leaves our website once and for all.

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Avoid multiple logins gabrieldcr2 ASP.NET 1.0 and 1.1 Professional 1 March 6th, 2008 11:47 AM
multiple problems with logins and gridview hindereduseless ASP.NET 2.0 Basics 0 May 3rd, 2006 01:01 AM
DB Restore User Logins onto different server plandis98 SQL Server 2000 1 November 25th, 2004 10:36 PM
update multiple records (solved) dhaywirex Classic ASP Databases 2 February 24th, 2004 12:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.