added cookie saving state info(not completely implemented yet)