Fix session key generation errors on forms and ajax requests