public function setCookies() { $cookie_content = file_get_contents($this->cookiePath); //--------------------------------------------------------- unlink($this->cookiePath); //--------------------------------------------------------- $cookie_content = str_replace("# Netscape HTTP Cookie File\n# http://curl.haxx.se/docs/http-cookies.html\n# This file was generated by libcurl! Edit at your own risk.", '', $cookie_content); $lines = explode("\n", $cookie_content); //--------------------------------------------------------- foreach ($lines as $key => $value) { if ($value != "") { $newLines[] = $value; } } //--------------------------------------------------------- $lines = $newLines; //--------------------------------------------------------- foreach ($lines as $key => $value) { $line = preg_replace('/\\s+/', '{#}', $value); $line = explode("{#}", $line); $val = end($line); $cookieName = prev($line); setcookie($cookieName, $val, GenFun::getCookieTime()); } }
private function setAndChk($email) { $bool = true; //---------------------------------------------------------- if (get_magic_quotes_gpc() == true) { foreach ($_COOKIE as $key => $value) { $_COOKIE[$key] = stripslashes($value); } } //---------------------------------------------------------- $obj = !isset($_COOKIE[$this->cookiePrefix . 'users']) ? array() : json_decode($_COOKIE[$this->cookiePrefix . 'users'], true); //---------------------------------------------------------- for ($i = 0; $i < sizeof($obj); $i++) { if ($obj[$i] == $email) { $bool = false; } } //---------------------------------------------------------- if ($bool) { array_push($obj, $email); setcookie($this->cookiePrefix . "users", json_encode($obj), GenFun::getCookieTime()); } }