Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Autosave then exit

by phildeman (Beadle)
on Jan 30, 2009 at 15:58 UTC ( #740217=perlquestion: print w/replies, xml ) Need Help??
phildeman has asked for the wisdom of the Perl Monks concerning the following question:

Does anybody have application that autosaves data from a web form, if the user takes too long to click the submit button?

Replies are listed 'Best First'.
Re: Autosave then exit
by mr_mischief (Monsignor) on Jan 30, 2009 at 16:11 UTC
    Do you mean saving data the server already has? The difficulty otherwise is that your web application's server end has no idea why the submit button hasn't been clicked on the client side. It could be that the user is thinking, that she went for a break, that he closed the browser, that her power went off, or that his computer blew up in a ball of sparks.

    If the browser is still open, you could have JavaScript on the client side (if that's enabled) submit after a certain period of time. That has nothing really to do with what language is on the server side, though.

    If you have data in a session on the server side and want to save changes in a more permanent way, you could set an alarm handler or some other type of timer in the server-side code. Be very careful in environments that share code, such as mod_perl, that you're not causing huge reentry headaches for yourself.

    Without some more specific idea of what you wish to accomplish, I'm not sure how much more advice anyone can give.

      So, I have an application that I am writing for our Intranet. The client wants the session to last at least 2 hours or more, because users are interrupted all the time. My argument is that this enables users to be careless and walk away from their machines. Nonetheless, if I can save the data that is on the form, and subsequently force the application to log them out, I can keep the session time less than 1 hour.

      My intention is to put as little data as possible on the session, meaning nothing to with the form data. With regards to reentry, I will always test the data to see if it exists before attempting to create a new record.

      I guess I can use JavaScript, my only concern is if any user has disabled JavaScript on their browser, then they will potentially loose data, if the session time runs out.

        Normally they won't loose any data, because in their browser they still have all the data in the form

        What you can do on the server side is ensure that when they try to submit that data after their session has run out, that that data gets accepted after login. So they get asked for username and password again and if that is correct either the server has remembered the form data and submits it automatically or they get forwarded to the page they had been with the form data they had at that time filled in. Then they just have to klick the submit button again

        You still have a fundamental limitation of the form data that's in the browser and not submitted not being present on the server. If it's a multi-part form that has had data previously submitted, you can save the already submitted data. If the browser is closed without submitting part of the data, there is no way for the server to get that portion of the data at all.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://740217]
Approved by ikegami
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2018-03-21 02:19 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (263 votes). Check out past polls.