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?
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?
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
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