Load Runner Ajax Truclient

Hi,

I recorded my entire business scenario in Action() block of ajax truclient and it is working fine while replay. But when i  copy paste the login part in init() and logout part in end() block, the script is failing in Action() block. Is there any Run Time setting that i am missing? to make the flow works across all blocks.

Any help would be appreciated.