I wrote a class to set and expire browser cookies. I'm trying to set the classes public variables to the value of a global variable in a way that would allow me to use the classes methods statically. Basically all I want to do is remove the duplicate global $settings
, and the $expire
and $domain
variables.
Here's my code as it sits:
<?php
class cookies {
public static function set($name, $value, $date = false) {
global $settings;
$expire = ($date) ? $date : $settings['expire'];
$domain = str_replace('www.', '', $settings['domain']);
setcookie($name, $value, $expire, '/', $domain);
}
public static function clear() {
global $settings;
$domain = str_replace('www.', '', $settings['domain']);
setcookie('test1', '', 1, '/', $domain);
setcookie('test2', '', 1, '/', $domain);
}
}
?>