Link to home
Start Free TrialLog in
Avatar of arcdogl
arcdogl

asked on

Refresh POST problem

Hello,

Part of my system is used to log user events, so for example a user will click a button to say they have started a process and then click again to say they have stopped. I encounter a problem when someone refreshes the page or browses back to a page and the event is submitted again. The way I have stopped this in the past is if the event POSTed is the current event then it must be an accident so ignore it - for example if you click to start but its already in a started state.

Is there a better way of doing this as the way i'm doing it now seems a bit messy?
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Hellom, arcdogl, Limited Member and welcome to EE.  One helpful thought for you, going forward, is that Experts answer questions for points here.  If you look at the number of 500-point posts in this zone, you will see that a 75-point post may not get as much attention - simple economics.

If I understand your situation correctly, you have some dependence on "stateful" information that is disrupted by browser window mechanics.  This is a common situation when one relies on sessions to keep the state of the client machine.  A variation on this theme occurs when your client has more than one browser window open - the sessions can persist even though the server-side logic would suggest that the session should disappear after the window is closed.

Suggest you consider putting your information into a data base and letting each page load bring in a new copy of the data.  Then you can have timestamp-tracking and other technologies to help keep track of things.

Best regards, ~Ray
Avatar of arcdogl
arcdogl

ASKER

Hi Ray,

I apreciate your comment about the points so I've increased them slightly.

my data is stored in a database and pulled in each time but when a user submits a form, for example to update the database, and the form is posted, if they then refresh the page it is posted again and unless I catch it it's entered into the database again. ideally I would prefer so that even if the user pressed refresh the form wasn't reposted at all.

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of arcdogl

ASKER

Hi Ray,

Sorry it's took me so long to reply.

Yes, that seems a much nicer way to do it. so its merging the full POST or GET string, encoding it and storing it in the session.
Thanks for the points - it's a good question! ~Ray