Clearing a variable in a database thru ASP

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Clearing a variable in a database thru ASP

    Hello All

    I have a website which has login and logoff features. When some one logs in,
    I set a variable in the database to 1 and if he logs off, I set it to 0.
    This is fine as long as the user actually clicks the button. If the user
    were to just close down the browser, the variable would never get set to 0
    and hence the next user would never be able to login until some one manually
    sets that variable to 0. Is there any way to trap the windows close event
    and update the database field on the happening of such event. Also would
    such code be need to be included in all the pages of the website. I am using
    frames and logoff feature is always displayed once the user logs in. The
    right frame is where I display all relevant information for the website.

    Examples would really be helpful

    Thanks


    Rahul Chatterjee Guest

  2. Similar Questions and Discussions

    1. Variable in database query?
      Here is a function I am attempting to use in a web application I'm developining. Basically, I am attempting to create a function to generate a...
    2. ASP SQL Server Database Login - Session Variable
      Hello, I have a tough one for you guys. (Atleast I've been pulling my hair out trying to figure this one out.) Thanks for taking a look at this...
    3. image into variable or database
      hello, i want to have an image in a variable so i can show it were ever i want the only catch is that i want the image to be called in the same...
    4. ASP Email - clearing out a variable
      I've got this code: With cdoMessage Set .Configuration = cdoConfig .From = strEmail .To = "donald.duck@disney.com" .Cc = strmEmail .Subject =...
    5. I need help. I am having trouble clearing a field in an Access database.
      I don't know what to use to clear a field in an MSAccess database. I can update fields in the database and delete whole records but I have not...
  3. #2

    Default Re: Clearing a variable in a database thru ASP

    Rahul Chatterjee wrote:
    > Hello All
    >
    > I have a website which has login and logoff features. When some one
    > logs in, I set a variable in the database to 1 and if he logs off, I
    > set it to 0. This is fine as long as the user actually clicks the
    > button. If the user were to just close down the browser, the variable
    > would never get set to 0 and hence the next user would never be able
    > to login until some one manually sets that variable to 0. Is there
    > any way to trap the windows close event and update the database field
    > on the happening of such event. Also would such code be need to be
    > included in all the pages of the website. I am using frames and
    > logoff feature is always displayed once the user logs in. The right
    > frame is where I display all relevant information for the website.
    >
    > Examples would really be helpful
    >
    > Thanks
    This article, and the two aricles it links to, may be helpful.
    [url]http://www.aspfaq.com/show.asp?id=2095[/url]

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  4. #3

    Default Re: Clearing a variable in a database thru ASP

    Rahul Chatterjee wrote on 09 jun 2004 in
    microsoft.public.inetserver.asp.db:
    > I have a website which has login and logoff features. When some one
    > logs in, I set a variable in the database to 1 and if he logs off, I
    > set it to 0. This is fine as long as the user actually clicks the
    > button. If the user were to just close down the browser, the variable
    > would never get set to 0 and hence the next user would never be able
    > to login until some one manually sets that variable to 0. Is there any
    > way to trap the windows close event and update the database field on
    > the happening of such event. Also would such code be need to be
    > included in all the pages of the website. I am using frames and logoff
    > feature is always displayed once the user logs in. The right frame is
    > where I display all relevant information for the website.
    >
    > Examples would really be helpful
    >
    Since you cannot know, if a not logged out user has "left", the only
    solution is to define a timeout time.

    Do not put a 1 in your database position, but the actual time.
    Refresh the time at every contact with the user.

    If another user wants to log in [I suppose you want to limit the number of
    concurrent users for some reason] all users datetimes are checked first
    against the actual time and deleted where timed out.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan. Guest

  5. #4

    Default Re: Clearing a variable in a database thru ASP

    I am really trying to prevent multiple users logging in with the same id
    - for eg for one office, there is one ID and multiple users know that id
    (I cant generate more ID's) and I want only one user on the system at a
    time. I achieved this by the use of the flag 1(for logged in) and 0 for
    logged out. But in the event if the user just shut the browser down,
    this would cause the flag not to be updated.





    *** Sent via Devdex [url]http://www.devdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Rahul Chatterjee Guest

  6. #5

    Default Re: Clearing a variable in a database thru ASP

    If you have a frameset that is present during the entire time the user is
    logged on then you could add an onunload event which calls the logoff page
    in a popup window (have the logoff page close itself).

    or

    When a user logs on assign a unique "logon session" id and save the login id
    and the logon session id in the database. Put the logon session id in a
    session var or a cookie as well. Change your "logged on" test code to use
    the logon session id to determine if the current user is logged on. When the
    user logs off clear the entry for the logon session id in the database

    At the time a user tries to log on, look for the login id (not the unique
    "logon session" id). If it exists, then display a message that someone is
    already logged on with that id.

    To clear the ID, you can:

    allow the user attempting to log on to "bump" the existing session off
    by clearing the entry in the database.
    allow an "administrative" user to clear sessions
    use a time-stamp and a periodic batch script to clear sessions.

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    [url]www.ielearning.com[/url]


    "Rahul Chatterjee" <rahul@benesysinc.com> wrote in message
    news:OAq7W1jTEHA.332@TK2MSFTNGP11.phx.gbl...
    > I am really trying to prevent multiple users logging in with the same id
    > - for eg for one office, there is one ID and multiple users know that id
    > (I cant generate more ID's) and I want only one user on the system at a
    > time. I achieved this by the use of the flag 1(for logged in) and 0 for
    > logged out. But in the event if the user just shut the browser down,
    > this would cause the flag not to be updated.
    >
    >
    >
    >
    >
    > *** Sent via Devdex [url]http://www.devdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Mark Schupp Guest

  7. #6

    Default Re: Clearing a variable in a database thru ASP

    Rahul Chatterjee wrote on 09 jun 2004 in
    microsoft.public.inetserver.asp.db:
    > I am really trying to prevent multiple users logging in with the same id
    > - for eg for one office, there is one ID and multiple users know that id
    > (I cant generate more ID's) and I want only one user on the system at a
    > time. I achieved this by the use of the flag 1(for logged in) and 0 for
    > logged out. But in the event if the user just shut the browser down,
    > this would cause the flag not to be updated.
    As I just said, use a timeout.

    [please quote part of the posting you are answering,
    others want to be able to follow the thread too]



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan. Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139