开发者

Should I access cookies from Model or from Controller?

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜