Cherry picked Build cookie support part I. Fixes #6, #11, #12

Commit: db6e0b3ecadf8b23c2f04ad0cab2e0fc5f76f3e5 [db6e0b3]
added Cookie management functions to the model