Search code examples
phphttpsetcookie

how to set domain in setcookies()


I have tried setting cookies but the problem is in setting domain. When i tried to set domain in setcookies() it doesn't set any value. Without domain setting it will automatically set my domain (for ex. localhost).

If I am using any .com it will set it by default but I cannot set domain in cookies.

Can any one please help me setting domain in php.

  setcookie('session_id',$sessionID[1],strtotime($expireTime[1]),'/',$domain);

When I set it without domain it sets the cookies to my localhost or on which domain I am.

Can any one help me.


Solution

  • you can not set a cookie attributed to a domain other than that you are using. this is generally considered a good thing.