You are probably missing that you would need to set the session variables on the page specified as the action of the form. If it works with no action, copy and paste the code on top of the form page to the top of the form action page and that would work once you update the action.