PHP Exceptions Question

I have a login script that works like this:

form –> script/object –> class

The user fills in the login form, data is $_POST’ed to the login_script that creates
a new object.

When I throw an exception in the class, it goes back to the script/object page because that’s where the try block / object is… is there a way to send the exception back to the form, so I can display the error there, w/o using $_GET? I’m not allowed to use $_GET in this project for security reasons and permalink / htaccess stuff…

Use S_SESSION to store the exception if you are using sessions. If not then just call session_start at the top of each php file and you will be…

Alternatively a technique I used once when I was modding somebody elses code was to write a text file where the name was an md5 hash of the users ip address with a standard string prepended like ER-d47e8de3e38d8045459477aa12f1691d.txt and put the message in there. then the form can look for a text file (since it knows the ip address it can calculate the file name) delete the text file after obtaining the message and look for all instances of filenames starting with ER- that are over a day old and delete them too (since some instances will be terminated early by the server).

IMHO, I don’t think that is the best approach, as many clients (web browsers) might be coming from the same IP address at the same time.

Oh yeah, sessions LOL… I am using sessions, so just set it as a variable, and put a header redirect in the catch, and then call the session var on the login form and destroy it once it’s been used?

Yeah you are right Alan - not the best but works 99% of the time and it was for handling a rare even so probability of failure was acceptable. It was only a ‘bell and whistle’ feature-not mission critical. I just wanted to avoid digging into somebody elses code far enough to assure myself that any other approach would not cause problems - ie no S_SESSION=array() or similar nasties. As I recall there were about 200 script files in the app!

Yep -thats the idea.