CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Knows when a user has disconnected from a page

 



solutionmaster
New User

Oct 5, 2007, 7:57 AM

Post #1 of 4 (2563 views)
Knows when a user has disconnected from a page Can't Post

I'm trying to write a program that will connect to either MySql or Oracle to store information from a html form. After the information is stored, there will be another web page that will retrieve the data from the database. Simple enough. The problem is that i can only allow one user to see the next available record and lock it in a way that no one else will be able to see that same record; only the next available. So i thought of creating a column on the table that would be marked "unavailable" as soon as the web page is opened and the first record is accessed. okay well, what if the user never clicks on submit to mark the record as "completed" or leaves the computer on indefinitely or the browser crashes. At that point, the record will be marked unavailable forever since any future users will not be able to pull it up. is there any way to:
1) timeout the time it takes for a user to view a record

2) let my script know that the connection between the user and the server has been lost, so i can mark the record "available" and another user can work on it.


KevinR
Veteran


Oct 5, 2007, 9:14 AM

Post #2 of 4 (2562 views)
Re: [solutionmaster] Knows when a user has disconnected from a page [In reply to] Can't Post

You could add a line/field to the record that indicates if it is pending or finished. When marked as pending there can also be a field that stores the time the record was created. If another user comes along and the program sees the record as pending but the time has expired then proceed as necessary.
-------------------------------------------------


solutionmaster
New User

Oct 5, 2007, 10:01 AM

Post #3 of 4 (2560 views)
Re: [KevinR] Knows when a user has disconnected from a page [In reply to] Can't Post

That sounds feasible and more than likely what I'm going to do for timeouts. Thanks KevinR.

Any suggestions for the second part? because if i timeout after a certain amount of time, it will make records locked for that time regardless of browser or computer failure. So let's say i give 30 minutes for a user to access a record and get all necessary info from it. If the user then closes the browser after 2 minutes without completing the request, how can i let my script know that it is available to everybody else and not have to wait 28 minutes?

Thanks in advance


KevinR
Veteran


Oct 5, 2007, 10:43 AM

Post #4 of 4 (2559 views)
Re: [solutionmaster] Knows when a user has disconnected from a page [In reply to] Can't Post

You will have to use a session that tracks the user while on the website. If the user has no activity for a certain amount of time the session expires and the user has to start over again. The record would be released when the session expires making available to the next user.

CGI::Session is one such module, there might be others. Sessions usually have to be included at the lowest level of your CGI scripts so hopefully you have not written too much code yet. Trying to add them to already existing CGI scripts can be quite a chore.

I personally don't have too much practical experience with sessions so will not be of much use to help with actual code or how to use the module. I beleive there is a 'cookbook' though for CGI::Sessions, search cpan.
-------------------------------------------------


(This post was edited by KevinR on Oct 5, 2007, 10:44 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives