Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Jan 2003
    Location
    Georgia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Multiple Login Question

    Is there a way of stopping a user from logging in twice during
    the same session? Right now, the user can log in as many times as he or she wants to from multile machines. I need a message box opening up saying that the user is already logged in or something.

    The school system I work for are primarily MAC driven computers and they do not handle cookies the same as PCs do, so unfortunately that is out of the question. What I am trying to do is to prevent a repetitive user logging in twice and block so that only one user under a certain name can login in at one time.

    Currently, I have a datediff command that writes the time they login to the database and next time they login, the datediff compares the previous time to the current time and if it is less than 20 minutes they cannot log in. Though this works, it polls the database every time a user logs in. A lot of stress is being implemented. Is there an easier way to get this happen. Below is my datediff entry:

    Code:
    iNumberMinutes = 20 
    
    If DateDiff("n",rs("lastAccess"),Now()) < iNumberMinutes Then
    Response.Redirect("login.asp?login=loggedin")	
      rs.Close
      conn.Close
      set rs=nothing
      set conn=nothing
      Response.End
    End If
    			
    rs.Close
    		
    strSQL = "UPDATE userlist SET lastAccess = #" & Now() & "# WHERE username = '" & Session("Name") & "'"
    
    conn.Execute(strSQL)
    Any help would be greatly appreciated.
    Thanks, Phillip

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Normally what i do i will create a database and store all the login users into a table, then i can check thier login.
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Use session variable. Once they successfully logged in, set a session variable to something, say, session("username"). Then in each of your pages, check if the session variable contains something (the session variable is initialized to empty in the Session_OnEnd in the global.asa). If it is empty, it means that the user has not logged in.

    if session("username")="" then
    response.redirect("login.asp")
    end if

  • #4
    New Coder
    Join Date
    Jan 2003
    Location
    Peterborough, UK
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use session variable. Once they successfully logged in, set a session variable to something, say, session("username"). Then in each of your pages, check if the session variable contains something (the session variable is initialized to empty in the Session_OnEnd in the global.asa). If it is empty, it means that the user has not logged in.
    This wouldn't work if the user tried to log in from a different machine! The session variable applies to the user session, and is not available to another user.

    Ninja Turtle's solution is the way I would do it.

  • #5
    New Coder
    Join Date
    Jan 2003
    Location
    Georgia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    A little further explanation os required

    <'Ninja Turtle's solution is the way I would do it.'>

    Can either Ninja Turtle or Raven or anyone for that matter, elaborate on what this means please.

    Thanks, Phillip

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The way you're doing it should be ok - is it creating serious problems? You might need to look at using SQL Server or something instead of Access...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts
    dear philips,

    Sure, u have a login screen rite, so after user login, save their id into a table may be called USERLOGIN, save their login datetime, and ofcos their ID, and a login status.

    then u havae their record in the database u can do checking b4 they login to ur Application.

    Got it?
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    have an extra field in the database called loggedin or something and on login set the value to 1 and on logout set it to 0. Si when they login it looks up the password and also have it lookup to see if the field loggedin is 1 and if it is redirect or alert them

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #9
    New Coder
    Join Date
    Jan 2003
    Location
    Georgia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wow! What a response

    I am implementing all idea from everyone who contributed. Thank you Ninja Turtle, gleengv, scroots, and whammy. There is not too many problems on myh end just good questions from the manager. I think they all have been answered.

    I will create a field in my database that checks for logged in and sets it for 1. Request that field on everypage (his fear is - is the database being polled on every page and won't that be harmful to the server -- being hit that hard every page and all.) to be 1. if not 1, redirect back to login.asp.

    I read something about the differences in Access and SQL last night and what I read told me that SQL does field detection different than Access. Can someone elaborate on this. Access can also only do 15-20 simultaneous connections at the same time without erroring out or locking up. Was this correct?

    How much will the syntax change to go to SQL v/s Access? Thank you again for all who helped me through this.
    Last edited by phillip_ewing; 02-08-2003 at 05:03 PM.

  • #10
    Regular Coder
    Join Date
    Sep 2002
    Location
    London
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Does this link too your other query???

    Not sure, but I guess this links to your other query about whether someone has logged out..

    that way, rather than use a bit field for logged in/out use the loginDate and logoutDate fields.

    Re: Access vs. SQL - I'd go with SQL - EVERY TIME. Access is OK if you're doing a tiny project with very few visitors, but site performance will degrade significantly if you start to get a significant number of visitors....

    dominicall
    dominicall - confusing himself more and more each day

  • #11
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Access is OK if you're doing a tiny project with very few visitors, but site performance will degrade significantly if you start to get a significant number of visitors....
    Sorry to wander off-topic, but I was wondering about this myself. I've always been under the impression that Access is no good for web use because it'll screw up with more that 15-20 concurrent users.

    I've just started with a big travel agency, who run 30-40 different sites off individual Access databases. I don't know exact figures, but some of those sites get around 10,000 individual visitors a week.

    Sure, if you spread that out over a week, then maybe you're not going to get 20 users accessing a database at the same time, but I still reckon that, with that many visitors, you stand a fair chance of getting it. And these Access databases never screw up. Well, not much, anyway

    Anyone have any related info? Is Access really quite stable, or are we pushing the limits of what it can handle?

  • #12
    Regular Coder
    Join Date
    Sep 2002
    Location
    London
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access vs SQL

    You may well be right - I had one bad experience with Access a few years ago that has put me off ever since... only use it now if client isn't prepared to come up with cash to pay for SQL hosting.

    There a significant number of other benefits to SQL on top of the whole visitor number/scalability issue.

    Two of the most important ones that I use all the time are the use of stored procedures and data shaping.

    Sure, you can use queries instead of stored procedures in Access and recordset grouping instead of data shaping, but they're a lot less efficient in Access...

    From all the evidence I've seen, the performance gain of using parameterised (UK English spelling - LOL) queries in Access is negligible whereas the gains in SQL can be significant.

    There's a good article on 15seconds here...

    http://www.15seconds.com/issue/020919.htm

    Likewise, data shaping in SQL, once you can get your head round it, is a much better tool than recordset grouping in Access for creating hierarchical recordsets.

    There's also the simple fact that SQL is a whole lot quicker anyway.

    Taking your example of multiple sites using different Access databases is a good case in point. Assuming that the same database structure is used for each office then the more efficient option would be to create one large SQL database for all offices - each site can feed of the database using the same calls, just with different GUIDs for pulling and storing the data. Then, if you add another office all you need to do is to add the relevant GUIDs to the database and start adding content.

    Commercially, you also probably get a better deal on hosting costs - with better performance. I don't know what you pay for hosting, but lets say it's 30/month per site in a good quality shared server environment - that equates to 1200/month for 40 sites.

    You could either go to one hosting company and look for a good deal for dedicated hosting, or alternatively investigate co-location - buying and setting up your own server and then just paying co-location at a good host. After 4-5 months you'd pay for all the kit and software outright so could buy a web server and separate SQL server. All you'd then have to pay would be one co-location cost each month. Assuming that comes in at 200/month you're still saving significantly in the long term.

    The performance gain would be significant - there would only be your sites on the server and your database on the SQL server so overall performance gains would be very good.

    Just a thought

    dominicall
    dominicall - confusing himself more and more each day


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •