I think you are getting confused between server side and client side applications.
Using an external PHP page to check if someone is logged in to allow access to a desktop application is possible but an awkward way to solve a problem.
I had a similar problem once, and all you need to do is create a file (or a collection of files) that return results to specific queries and then your desktop application would parse the output.
As rich and ashley have said, if you download the file the server will be downloading it much in the same way a web user would download it. The server is still executing the script before it uploads it to the client.
Tom