2

I have authentication logic that uses cookies. The model attributes are initialized from cookies, but this is done only when specific controller actions are called. Should I access my cookies directly from controller logic or make the models even fatter and implement cookies save/load in models?

1 Answer 1

12

Don't clutter your model with web based concerns. Remember that in theory the model should be relavant in other environments (say if you wanted to provide REST based APIs, or a desktop version). Access cookies in Controller or Service Layers.

1
  • 3
    I would go so far as to say not to get/set cookies in the service layers, unless you use some abstraction wrapper which provides strong typing, as you don't really want magic strings lying around in these layers. Nov 4, 2009 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.