In case you can’t set a cookie from PHP when testing locally (localhost) with MAMP, you have to check « output_buffering » in your php.ini file.
Go to the right MAMP folder that contains the php.ini file. Be careful, there is probably several directories related to php.
On my Mac (MAMP 2.0.5), the path is :
Default php.ini file :