Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

page restrictrd to one user @ a given time

Status
Not open for further replies.

johk02

Programmer
Aug 20, 2003
169
AU
Hi,
I building an intranet page where we enter data into a database. Is it possible to restrict it so that only one user can use it at a given time

Thanks jonas
 
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.
 
Latest college project ???


thread333-834336



Chris.

Indifference will be the downfall of mankind, but who cares?
 
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.

Jonas
 
application("users")=0

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:

Application("NumUsers") = 0
server.redirect "home.htm"

As outlined, this is very simple (it does need them to press Logout, eg) but plenty of validation could be added.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top