One way would be to use an Application variable as a flag, so when someone goes to the data entry screen it checks the status of the variable, eg Application("PageLocked").
If the variable is False, eg, then no one is using it so you set the variable to True to "lock" the page.
When someone else goes to the page, if the variable is True, you redirect them somewhere else ("page-in-use.asp") so they know that someone else is using it.
When the "active user" has finished and leaves the data entry page, you set the variable back to False, so someone else can get in.
You should also put something in the globas.asa Sesssion End procedure that sets the variable to false when the user times out, in case they didn't log out properly.
You should also provide an Admin "back door" to reset the variable and kick people off, Just In Case.
I am not doing this for a homework
This is a form for work where we enter /log the emails. Thats why I need to restrict it so just one user canuse the page at a time.
I haven't been able to figure out how to lock one page so I proberly will end up doing something like this:
Global.asa
<script language="vbscript" runat="server">
Sub Application_OnStart
application("users")=1
End Sub
</script>
and then put this code in a javscript pop-up on page onload
There are
<%
Response.Write(Application("users"))
%>
active connections.
Then at least the user can see if someone is using the page or not.
Your count won't be 1 until someone is using the data entry page.
To set the count to 1 in the data entry page:
If Application("NumUsers") = 0 Then
Application("NumUsers") = 1
Else
server.transfer "pageislocked.htm"
End if
To set it back to 0, provide a method for them to "logout" of data entry, eg a simple form:
<form method="post" action="logout.asp">
<input type="Submit" value="Logout">
</form
logout.asp just resets the user count and redirects them to a valid page:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.