-1

Is it possible to set the path and domain one time at the beginning of the script and have all future sets conform to the same?

From the docs:

 bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] )
Supericy
  • 5,866
  • 1
  • 21
  • 25
user1032531
  • 24,767
  • 68
  • 217
  • 387
  • write a function to do it –  Feb 12 '13 at 02:16
  • @Dagon. Please explain. How will this allow setcookie() to use these domains/paths every time it is called? – user1032531 Feb 12 '13 at 02:18
  • 1
    just as Jon says, and remember you don't have to set all those values, some of the defaults may be what you want in the first instance. –  Feb 12 '13 at 02:24

1 Answers1

1

sure:

function own_setcookie($name, $value, $expire=0) {
    setcookie($name, $value , $expire, 'myPath', 'myDomain');
}

then use:

own_setcookie('myName', 'myValue');
Jon
  • 4,746
  • 2
  • 24
  • 37
  • Ah, now I understand Dagon's comment. Makes sense. Do you typically use this approach, or are you just addressing my question? Thanks!!! – user1032531 Feb 12 '13 at 02:21
  • I actually use a cookie handler class that I created, but it does function along the same lines of defaulting values like this function does. ^^ – Jon Feb 12 '13 at 02:22