Added set_cookie() method and reduced duplicate code.
Merge pull request #9 from pippinsplugins/master

Add new set_cookie() method