I’m developing on my Mac notebook, I use MAMP. I’m trying to set a cookie with PHP, and I can’t. I’ve left off the domain, I’ve tried using ‘\’ for the domain. No luck.
setcookie('username', 'George', false, '/', false); setcookie('name','Joe');
I must be missing something obvious. I need a quick and simple solution to this. Is there one?
I’m not doing anything fancy, simply loading (via MAMP) the page, http://localhost:8888/MAMP/lynn/setcookie.php
That script has the setcookie code at the top, prior to even writing the HTML tags. (although I tried it in the BODY as well). I load the page in various browsers, then open the cookie listing. I know the browsers accept cookies, because I see current ones in the list. Just not my new one.
From the docs:
Is that it?
edit:
Can you see the cookie being sent by the server, e.g. by using the Firefox extension Tamper Data, or telnet? Can you see it being sent back by the browser on the next request? What’s the return value of setcookie()? Is it not working in all browsers, or just in some?