本文整理汇总了PHP中Cookie::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Cookie::save方法的具体用法?PHP Cookie::save怎么用?PHP Cookie::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cookie
的用法示例。
在下文中一共展示了Cookie::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
function process()
{
$siteAdmin = $this->needASiteAdminSelected();
if ($siteAdmin) {
$choice = $this->request->getConfirmedState();
$cookieSet = false;
// is the cookie already set or not?
if (isset($_COOKIE[COOKIE_NAME_NO_STAT . $siteAdmin])) {
$cookieSet = true;
}
if ($choice == 1) {
$ck = new Cookie(COOKIE_NAME_NO_STAT . $siteAdmin);
if ($cookieSet) {
$ck->delete();
} else {
$ck->save();
}
$this->setMessage();
} else {
if ($cookieSet) {
$this->tpl->assign("cookie_no_stat", true);
} else {
$this->tpl->assign("cookie_no_stat", false);
}
}
}
}
示例2: indexAction
public function indexAction()
{
Cookie::save("hello", "world");
//reids
//SRedis::set("test",time());
//SRedis::get("test");
//Log
//Log::useDailyFiles(BASE_PATH . "/app/logs/custom.log", 7);
//Log::info("this is custom file");
return View::make('index', ["cookie" => Cookie::get("hello")]);
}
示例3: Lang
function Lang()
{
$c = new Cookie(COOKIE_NAME_VIEW);
// look if reload lang file
$this->fileAdress = INCLUDE_PATH . "/config/lang_available.php";
if (!file_exists($this->fileAdress)) {
$this->reloadLangFile();
} else {
require $this->fileAdress;
if (!isset($langAvailable)) {
print "There is a problem with the /config/lang_available.php file.";
$langAvailableFile = INCLUDE_PATH . "/config/lang_available.php";
if (!unlink($langAvailableFile)) {
print "Error when trying to delete {$langAvailableFile}. You have to delete the file {$langAvailableFile} manually.";
}
print "<br>Please refresh this page";
exit;
}
$this->langAvailable = $langAvailable;
}
$langRequest = Request::getLang();
if (!file_exists(LANGS_PATH . "/" . $langRequest)) {
// cookie ?
if (($langRequest = $c->getVar('lang')) && file_exists(LANGS_PATH . "/" . $langRequest)) {
$this->file = $langRequest;
} else {
// default lang?
if (defined('INTERFACE_DEFAULT_LANG') && file_exists(LANGS_PATH . "/" . INTERFACE_DEFAULT_LANG)) {
$this->file = INTERFACE_DEFAULT_LANG;
}
}
} else {
$this->file = $langRequest;
}
// if lang not found in REQUEST + COOKIE + not set with INTERFACE_DEFAULT_LANG
// then we try to choose the better lang
if (!isset($this->file) || !strpos($this->file, 'utf-8.php') || strpos($this->file, '..') !== FALSE) {
$this->file = $this->getNearestLang();
}
$this->setLang();
// cookie
$c->setVar('lang', $this->file);
$c->save();
//print($c->toString());
//print($this->file);
}
示例4: setCookie
public static function setCookie($user, $name, $value, $expires)
{
//self::cleanCookies();
$cookie = self::getCookieObject($user, $name);
if ($cookie) {
$cookie->setValue($value);
$cookie->setExpires(date("Y-m-d H:i:s", $expires));
$cookie->save();
} else {
$cookie = new Cookie();
$cookie->setUserId($user->getId());
$cookie->setName($name);
$cookie->setValue($value);
$cookie->setExpires(date("Y-m-d H:i:s", $expires));
$cookie->save();
}
}