How set .domain cookies?

How set .domain.com for all cookies?

No way how to set it globally, you have to set it via function parameter. You can make your own function, which you will use to set all cookies and in this function you can automatically set domain parameter for native call for all cookies.



10.8k

Hi, David.

I need set default domain ".domain.com" for all my cookies. Lest not to install this domain for each cookie.

Then you have to do extend standard cookies service or make your own, which will set this domain for you.

What exactly are you trying to accomplish? If you set a cookie - without specifying a domain - on http://foo.bar.com, that cookie will only be active for foo.bar.com. Are you wanting to make the cookie active for all of bar.com? If so, you can pass the domain to the set() method. There doesn't appear to be a global setting, but if you want one, it should be pretty straightforward to write your own class that extends Phalcon\Http\Response\Cookies and overrides set() - injecting the domain you want in a call to parent::set().