fix cookie handling and session deletion