refactoring cookie module