I have a form that checks whether or not the name/password was valid through a mysql database query. Now, if I were to use your function, how would I call it and set values from the form, onto the value parameter? What I mean is that if the form is already outputted, how am I supposed to validate and set a cookie (since the cookie is in the header and once a document is outputted, it doesn't work). The process is: Fill out the name/password Validate the name/password If true, set cookie, if false, don't set (or expire it). is it possible to do it all in 1 php page? Thanks a lot