Search code examples
phpcookiessetcookie

setrawcookie in PHP not working properly in FF and Chrome when domain and path set


This works in Safari, FF, Chrome, etc.:

setrawcookie('mycookie', 'myvalue', time() + 31556926);

This does not work in FF or Chrome:

setrawcookie('mycookie', 'myvalue', time() + 31556926, '/', '.localhost');

I have been using PHP for quite some time, and have never seen this behavior before.


Solution

  • Works now, was an issue with .localhost instead of .somedomain.com - updated the original question to reflect the broken code. (Morning coffee not kicked in yet)