Hi,
HTTP is a stateless protocol so your way of doing things is not correct. Will have to use some storage medium like mysql, file or session data to store the result.
Let me know in details how you would like to use the value, so that I can suggest most convenient solution.
Regards,
Samiran