Page 1 of 1

trapping repeatition

Posted: Tue Jul 05, 2005 3:09 am
by harrisonad
This is one of those refresh problem on browsers.
I have a single script that checks if it is already executed by user. It uses sessions.

Code: Select all

session_start();
if(!isset($_SESSION['executed'])){	
    /*
       bunch of codes here ...
    */	
    $_SESSION['executed'] = true;
}
Now, when the user will refresh this script after already executing it, it will not be excuted because of the if statement.
But from now on, every POST variables to be passed in this script will not work because the session is still alive.

Of course, you may say that I have to session_destroy() or unset() this session variable. But doing so, will disable my checking, making the script to be executed repeatedly on browser refresh.
Any idea on how or when to kill session without spoiling the checking?

Posted: Tue Jul 05, 2005 4:37 am
by dethron
dude either you are not talking english or i have some understanding problem :lol:

since you want to execute posted data again and again, i assume you want data replication or re-execution in your code :!:

however, if this is the case, why do you use session :?:

tell's us what you really want to do, so we can suggest some solutions 8)

Posted: Tue Jul 05, 2005 4:47 am
by djot
dethron, you were not the only one who did not understand his question :)

Posted: Tue Jul 05, 2005 5:01 am
by harrisonad
sorry bros. let me explain it again.
This script submits to itself, and process queries according to the variables passed, let's say, a application form.
Now, I want to protect this script from being reexecuted by browser refresh using sessions.

But anyway, nice talking with you.
I would have to answer it myself.

This topic closed.

Posted: Tue Jul 05, 2005 5:03 am
by dethron
8) dude you really rocks, i thought tailors have some problems with patching(sewing) their things :lol:

Posted: Tue Jul 05, 2005 5:07 am
by djot
You will have to put some unique code into your form, like tokens (unique ids) and store it in your session or DB. If you find an already sent token, you know that the form has been send before.

Posted: Tue Jul 05, 2005 6:44 am
by timvw

Posted: Tue Jul 05, 2005 7:44 pm
by harrisonad
Thanks tim, you really know how to cheer me up. :cry: :wink: :lol: