changed cookie and session handling to data operations carried out in last stage of processing rather than real-time calls, and removed convenience functions