Improve cookie handling during login