sessions and cookies refactored